OnJava8-Examples/threads/SerialNumberSupplier.java
2016-09-23 13:23:35 -06:00

12 lines
377 B
Java

// threads/SerialNumberSupplier.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
public class SerialNumberSupplier {
private static volatile int serialNumber = 0;
public static int nextSerialNumber() {
return serialNumber++; // Not thread-safe
}
}