OnJava8-Examples/concurrent/SerialNumberSupplier.java
2016-11-23 09:05:26 -08:00

12 lines
380 B
Java

// concurrent/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
}
}