classThreadLocal[T] extends java.lang.ThreadLocal[T] with () ⇒ T
The ThreadLocal gets initialized by the init that is passed in when needed.
And, because it just extends java.lang.ThreadLocal, you can also call set on it too.
Usage:
val tl = new ThreadLocal(System.currentTimeMillis)
// these three are all equivalent, and depends on your taste
tl.withValue { v => System.out.println(v) }
System.out.println(tl.get)
System.out.println(tl())
The ThreadLocal gets initialized by the init that is passed in when needed. And, because it just extends java.lang.ThreadLocal, you can also call set on it too.
Usage: val tl = new ThreadLocal(System.currentTimeMillis)
// these three are all equivalent, and depends on your taste tl.withValue { v => System.out.println(v) } System.out.println(tl.get) System.out.println(tl())