equal
deleted
inserted
replaced
129 |
129 |
130 /** |
130 /** |
131 * Creates a thread local variable. The initial value of the variable is |
131 * Creates a thread local variable. The initial value of the variable is |
132 * determined by invoking the {@code get} method on the {@code Supplier}. |
132 * determined by invoking the {@code get} method on the {@code Supplier}. |
133 * |
133 * |
|
134 * @param <S> the type of the thread local's value |
134 * @param supplier the supplier to be used to determine the initial value |
135 * @param supplier the supplier to be used to determine the initial value |
135 * @return a new thread local variable |
136 * @return a new thread local variable |
136 * @throws NullPointerException if the specified supplier is null |
137 * @throws NullPointerException if the specified supplier is null |
137 * @since 1.8 |
138 * @since 1.8 |
138 */ |
139 */ |
139 public static <T> ThreadLocal<T> withInitial(Supplier<? extends T> supplier) { |
140 public static <S> ThreadLocal<S> withInitial(Supplier<? extends S> supplier) { |
140 return new SuppliedThreadLocal<>(supplier); |
141 return new SuppliedThreadLocal<>(supplier); |
141 } |
142 } |
142 |
143 |
143 /** |
144 /** |
144 * Creates a thread local variable. |
145 * Creates a thread local variable. |