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

Java: How to create and run a thread

Java: How to create and run a thread
{filelink=10860}

  public class ThreadExemple extends Thread
  	{  
       public void run()
      {  
           for ( int i = 0; i < 10; i++ ) {  
               System.out.println("Thread principal:<span id="more-1113"></span> "+i);  
           }  
       }  
       public static void main(String[] args)
    {  
           ThreadExemple tt = new ThreadExemple();  
           	// Start the thread
           	tt.start();
           	for ( int i = 0; i < 10; i++ )
           	{
               System.out.println("Thread principal: "+i);  
           }  
   } 
  	}

No comments yet.

Leave a Comment