I have threadlock
and concurrentHashMap
. In some places of my code, I need to keep mapping from some object
to thread
, which should be secure in the thread. Use an option concurrent hashmap
and use a threadlock
. Any advantages / disadvantages for one of these methods, in terms of most of the speed?
This is definitely the case ThreadLocal values for the thread locale are stored in the thread object, a concurrent Instead of the map, so there is no locking at all, and therefore more efficient. Also keep in mind that the threads associated with threads are automatically discarded when thread is killed, which will not be with concurrent hashmap. One last thing, though: If you have threads that have been "reused" in some way, such as an employee in the pool, then you have to clean before returning the pool of pools to the pool.
Comments
Post a Comment