#108 Consistent package naming throughout the examples
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
package com.iluwatar.lazy.loading;
|
||||
|
||||
/**
|
||||
*
|
||||
* Same as HolderNaive but with added synchronization.
|
||||
* This implementation is thread safe, but each {@link #getHeavy()}
|
||||
* call costs additional synchronization overhead.
|
||||
*
|
||||
*/
|
||||
public class HolderThreadSafe {
|
||||
|
||||
private Heavy heavy;
|
||||
|
||||
public HolderThreadSafe() {
|
||||
System.out.println("HolderThreadSafe created");
|
||||
}
|
||||
|
||||
public synchronized Heavy getHeavy() {
|
||||
if (heavy == null) {
|
||||
heavy = new Heavy();
|
||||
}
|
||||
return heavy;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user