alcuni test su synchronized e singleton
This commit is contained in:
39
threads_test/test_2_singleton.java
Normal file
39
threads_test/test_2_singleton.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package threads_test;
|
||||
|
||||
/**
|
||||
* Created by Giovanni on 12/10/2014.
|
||||
*/
|
||||
public class test_2_singleton {
|
||||
|
||||
private test_2_singleton(){
|
||||
|
||||
a="initialized";
|
||||
|
||||
}
|
||||
|
||||
private String a;
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
private static class inner_test_2_singleton {
|
||||
|
||||
|
||||
private static final test_2_singleton x = new test_2_singleton() ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static test_2_singleton get_instance(){
|
||||
|
||||
return inner_test_2_singleton.x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user