What is a Thread identifer and how can I obtain it?
Created May 8, 2012
Brandon Rohlfs
A Threads identifer is a positive unique long value which is generated when a Thread is created. Using the following method a Threads identifer can be obtained.
public long getId()Here is a short example.........
class ThreadID{ public static void main(String[] args){ Thread t1 = new Thread("Thread one"); Thread t2 = new Thread("Thread two"); Thread t3 = new Thread("Thread three"); System.out.println(Thread.currentThread().getName()+ "'s" + " identifier is " + Thread.currentThread().getId()); System.out.println(t1.getName()+ "'s" + " identifier is " + t1.getId()); System.out.println(t2.getName()+ "'s" + " identifier is " + t2.getId()); System.out.println(t3.getName()+ "'s" + " identifier is " + t3.getId()); } }