OnJava8-Examples/concurrency/SerialNumberSupplier.java

9 lines
219 B
Java
Raw Normal View History

2015-11-03 12:00:44 -08:00
// concurrency/SerialNumberSupplier.java
2015-06-15 17:47:35 -07:00
2015-11-03 12:00:44 -08:00
public class SerialNumberSupplier {
2015-06-15 17:47:35 -07:00
private static volatile int serialNumber = 0;
public static int nextSerialNumber() {
return serialNumber++; // Not thread-safe
}
2015-09-07 11:44:36 -06:00
}