[concurrency-interest] Thread.getId()

Kasper Nielsen news@kav.dk
Mon, 26 Jan 2004 21:30:06 +0100


After having read the javadoc for Thread.getId()
public long getId()

Returns the identifier of this Thread. The thread ID is a positive long 
number generated when this thread was created. The thread ID is unique 
and remains unchanged during its lifetime. When a thread is terminated, 
this thread ID may be reused.
I think it should be prohibited for the jvm to reuse a thread id, I 
simply can't see any reason why it should be allowed. If people are 
using the id in anyway across of thread initialization/termination it 
could potentially lead to confusion and/or errors.

- Kasper