Reputation: 7719
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.
Upvotes: 4
Views: 1059
Reputation: 45443
Yes, people did that before Java had ThreadLocal
.
But now you probably should use ThreadLocal
.
Upvotes: 8