Skip to content

Instantly share code, notes, and snippets.

@javi830810
Created September 6, 2019 01:17
Show Gist options
  • Save javi830810/e42d9d55457e97b086d4eb9563a14973 to your computer and use it in GitHub Desktop.
Save javi830810/e42d9d55457e97b086d4eb9563a14973 to your computer and use it in GitHub Desktop.
public class MySingleton {
private static MySingleton instance;
private MySingleton() {
}
public static MySingleton create() {
if (instance == null) {
instance = new MySingleton();
}
return instance;
}
}
Thread t1 = new Thread();
t.Start(function() -> {
MySingleton p = MySingleton.create();
});
Thread t2 = new Thread();
t2.Start(function() -> {
MySingleton p = MySingleton.create();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment