/* Get Thread object and name (very meaningful)
The original thread has its own default name
thread-number This number starts from 0
Method of Thread Parent class
Static thread CurrentThread (): Gets the current thread object equivalent to this
GetName Get thread Name
*/
Class Text extends Thread
{
private String name;
Text (String name)
{
This.name=name;
Super (name); /* The parent class has methods to define the name of the thread */
}
public void Run ()
{
for (int i=0;i<60;i++)
{
System.out.println (name+ "Run---" +i);
System.one.println (Thread.CurrentThread (). GetName () + "Run---" +i);
}
}
}
Class Threadtext
{
public static void Main (String args[])
{
Text t1=new text ("one");
Text t2=new text ("both");
T1.start ();
T2.start ();
for (int i=0;i<60;i++)
{
System.out.println ("Main Run---" +i);
}
}
}
Java gets the object and name of the thread