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

Class SyncConstructor

concurrent/SynchronizedConstructor.java:7–17  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5import java.util.concurrent.atomic.*;
6
7class SyncConstructor implements HasID {
8 private final int id;
9 private static Object
10 constructorLock = new Object();
11 SyncConstructor(SharedArg sa) {
12 synchronized(constructorLock) {
13 id = sa.get();
14 }
15 }
16 @Override public int getID() { return id; }
17}
18
19public class SynchronizedConstructor {
20 public static void main(String[] args) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected