jdk/test/java/lang/ThreadLocal/ImmutableLocal.java
changeset 32649 2ee9017c7597
parent 5506 202f599c92aa
equal deleted inserted replaced
32648:1fa861caf840 32649:2ee9017c7597
    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();