I am working on a lock class to learn more on concurrency. What I am trying to do 开发者_开发百科is create a queued lock. A thread calls lock, is added to a queue and when the lock is released and the thread is first in line of the queue, it will be able to continue.
What I would like to know is: is there a way I can grab the thread that is currently running the lock code or do I have to pass the thread object into the lock as a parameter?
The static method Thread.currentThread
returns a reference to the currently executing Thread
object.
精彩评论