Removed locker object, using a synchronized method now.
This commit is contained in:
parent
efba812190
commit
7a6f56883d
@ -32,7 +32,6 @@ package sesim;
|
|||||||
*/
|
*/
|
||||||
public class IDGenerator {
|
public class IDGenerator {
|
||||||
|
|
||||||
private final Locker ID_LOCKER = new Locker();
|
|
||||||
private long next_id;
|
private long next_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,10 +55,7 @@ public class IDGenerator {
|
|||||||
*
|
*
|
||||||
* @return the next generated ID
|
* @return the next generated ID
|
||||||
*/
|
*/
|
||||||
public long getNext() {
|
public synchronized long getNext() {
|
||||||
ID_LOCKER.lock();
|
return next_id++;
|
||||||
long id = next_id++;
|
|
||||||
ID_LOCKER.unlock();
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user