Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to find and change the name of a thread

Java: How to find and change the name of a thread
{filelink=10862}

  public class ThreadName extends Thread
  	{
       private Thread mon_thread;
       public ThreadName()
       	{
          // the thread created by our class
           mon_thread = Thread.currentThread();
       }
       public void run()
       	{
           for ( int i = 0; i 0)
               		this.setName("Thread sakoba");
           }
       }
       // Find and display the name of the Thread
       public void afficherNom()
       	 {
           Thread t = Thread.currentThread();
           String name= t.getName();
           System.out.println ("running thread "+name+ " ");
       }
       public static void main(String[] argv)
       	{
           Thread thr = new ThreadName();
           thr.start();
       }
   }

Users who found this page were searching for:

  • java find a thread by name

No comments yet.

Leave a Comment