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

Java: Find the thread running in the virtual machine

Java: Find the thread running in the virtual machine
{filelink=10861}

  public class CurrentThread extends Thread
  	{
       private Thread thread_perso;  
       public CurrentThread()
       	{
          // get current thread
           thread_perso = Thread.currentThread();
       }  
       public void run()
       	{
           for ( int i = 0; i < 10; i++ )
           {  
               trouver_thread();  
           }  
       }  
       // Find and display the reference of current thread
       public void trouver_thread()
       	 {
           Thread t = Thread.currentThread();
           if ( t == thread_perso )
           	 {
               System.out.println("Running personal thread");
           } else if ( t == this )
           	{
               System.out.println("oop, nothing");  
          } 
       }
       public static void main(String[] argv)
       	{
           CurrentThread thr = new CurrentThread();
           thr.start();
           for ( int i = 0; i < 10; i++ )
           {
               thr.trouver_thread();
           }  
       }  
   }

Users who found this page were searching for:

  • create a thread with a gui button in python
  • local storage of emails
  • +perl create array for 30 days
  • java date subtract minutes
  • group python list items
  • use python to attach text file in email
  • python create a class

No comments yet.

Leave a Comment