/** * Generates sequential unique IDs starting with 1, 2, 3, and so on. *

* This class is not thread-safe unless you add "synchronized" to the method. *

*/ class BrokenUniqueIdGenerator { private long counter = 0; public long nextId() { long c = counter; c++; Thread.yield(); counter = c; return c; } }