From 7a6f56883d721efbe9920fed6609687e6b0e65df Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@maiol.ru> Date: Sat, 4 Feb 2017 23:17:46 +0100 Subject: [PATCH] Removed locker object, using a synchronized method now. --- src/main/java/sesim/IDGenerator.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/sesim/IDGenerator.java b/src/main/java/sesim/IDGenerator.java index 3cb5048..63cad4b 100644 --- a/src/main/java/sesim/IDGenerator.java +++ b/src/main/java/sesim/IDGenerator.java @@ -32,7 +32,6 @@ package sesim; */ public class IDGenerator { - private final Locker ID_LOCKER = new Locker(); private long next_id; /** @@ -56,10 +55,7 @@ public class IDGenerator { * * @return the next generated ID */ - public long getNext() { - ID_LOCKER.lock(); - long id = next_id++; - ID_LOCKER.unlock(); - return id; + public synchronized long getNext() { + return next_id++; } }