public K getCurrentKey ( ) { lock . lock ( ) ; try { Thread currentThread = Thread . currentThread ( ) ; for ( Entry < K , Thread > entry : threadMap . entrySet ( ) ) { if ( currentThread . equals ( entry . getValue ( ) ) ) { return entry . getKey ( ) ; } } return null ; } finally { lock . unlock ( ) ; } }
Returns key for current thread . Returns null if current thread is not part of the workflow .