Created
September 6, 2019 01:17
-
-
Save javi830810/e42d9d55457e97b086d4eb9563a14973 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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