MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / GuardedIDField

Class GuardedIDField

concurrent/GuardedIDField.java:7–15  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5import java.util.concurrent.atomic.*;
6
7public class GuardedIDField implements HasID {
8 private static AtomicInteger counter =
9 new AtomicInteger();
10 private int id = counter.getAndIncrement();
11 @Override public int getID() { return id; }
12 public static void main(String[] args) {
13 IDChecker.test(GuardedIDField::new);
14 }
15}
16/* Output:
170
18*/

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected