#107 JavaDoc for Singleton
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
package com.iluwatar.singleton;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.iluwatar.singleton.App;
|
||||
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
}
|
||||
}
|
||||
package com.iluwatar.singleton;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.iluwatar.singleton.App;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
}
|
||||
}
|
||||
|
@@ -5,9 +5,9 @@ import org.junit.Test;
|
||||
/**
|
||||
*
|
||||
* This test case demonstrates thread safety issues of lazy loaded Singleton implementation.
|
||||
*
|
||||
* <p>
|
||||
* Out of the box you should see the test output something like the following:
|
||||
*
|
||||
* <p>
|
||||
* Thread=Thread-4 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@6fde356e
|
||||
* Thread=Thread-2 creating instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@6fde356e
|
||||
* Thread=Thread-0 creating instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@6fde356e
|
||||
@@ -15,13 +15,17 @@ import org.junit.Test;
|
||||
* Thread=Thread-3 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@6fde356e
|
||||
* Thread=Thread-1 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@60f330b0
|
||||
* Thread=Thread-2 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@6fde356e
|
||||
*
|
||||
* <p>
|
||||
* By changing the method signature of LazyLoadedIvoryTower#getInstance from
|
||||
* <p><blockquote><pre>
|
||||
* public static LazyLoadedIvoryTower getInstance()
|
||||
* </pre></blockquote><p>
|
||||
* into
|
||||
* <p><blockquote><pre>
|
||||
* public synchronized static LazyLoadedIvoryTower getInstance()
|
||||
* </pre></blockquote><p>
|
||||
* you should see the test output change to something like the following:
|
||||
*
|
||||
* <p>
|
||||
* Thread=Thread-4 creating instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@3c688490
|
||||
* Thread=Thread-4 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@3c688490
|
||||
* Thread=Thread-0 got instance=com.iluwatar.singleton.LazyLoadedSingletonThreadSafetyTest$LazyLoadedIvoryTower@3c688490
|
||||
|
Reference in New Issue
Block a user