[concurrency-interest] ThreadLocal.getIfPresent()

Peter Levart peter.levart at gmail.com
Wed Jun 6 11:17:40 EDT 2018


Hello,

I thought I'd ask on this list, whether the following new method on 
ThreadLocal class would be useful, desirable or undesirable:

     /**
      * Returns the value in the current thread's copy of this
      * thread-local variable.  If the variable has no value for the
      * current thread, null is returned and no value is initialized.
      *
      * @return the current thread's value of this thread-local or null
      */
     T getIfPresent()


Might event be:

     Optional<T> getIfPresent();



Thanks, Peter



More information about the Concurrency-interest mailing list