equal
deleted
inserted
replaced
30 public class ImmutableLocal |
30 public class ImmutableLocal |
31 { |
31 { |
32 /** |
32 /** |
33 * {@link ThreadLocal} guaranteed to always return the same reference. |
33 * {@link ThreadLocal} guaranteed to always return the same reference. |
34 */ |
34 */ |
35 abstract public static class ImmutableThreadLocal extends ThreadLocal { |
35 public abstract static class ImmutableThreadLocal extends ThreadLocal { |
36 public void set(final Object value) { |
36 public void set(final Object value) { |
37 throw new RuntimeException("ImmutableThreadLocal set called"); |
37 throw new RuntimeException("ImmutableThreadLocal set called"); |
38 } |
38 } |
39 |
39 |
40 // force override |
40 // force override |
41 abstract protected Object initialValue(); |
41 protected abstract Object initialValue(); |
42 } |
42 } |
43 |
43 |
44 private static final ThreadLocal cache = new ImmutableThreadLocal() { |
44 private static final ThreadLocal cache = new ImmutableThreadLocal() { |
45 public Object initialValue() { |
45 public Object initialValue() { |
46 return Thread.currentThread().getName(); |
46 return Thread.currentThread().getName(); |