Current Thread

The currentThread() method returns a reference of currently executing thread.


\begin{lstlisting}
class TestMultiNaming2 extends Thread{
public void run(){
...
...new TestMultiNaming2();
\par
t1.start();
t2.start();
}
}
\end{lstlisting}

Test it Now


\begin{lstlisting}
Output:Thread-0
Thread-1
\end{lstlisting}