Is it possible to use Threads (Thread.getCurrentThread()) as keys in a collection (e.g. HashMap<Thread,Integer>). I know it’s possible! I’d like to know that whether Java creates unique hashCodes for threads.
Is it possible to use Threads (Thread.getCurrentThread()) as keys in a collection (e.g. HashMap<Thread,Integer>).
Share
Yes, people did that before Java had
ThreadLocal.But now you probably should use
ThreadLocal.