/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ari_thread2;
/**
*
* @author poltek
*/
class thread implements Runnable{
       Thread t;
       public thread(){
       t = new Thread (this,"Demo Thread");
       System.out.println("Thread anak mulai - " + t);
       t.start();
       }
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ari_thread2;
/**
*
* @author poltek
*/
class thread implements Runnable{
       Thread t;
       public thread(){
       t = new Thread (this,"Demo Thread");
       System.out.println("Thread anak mulai - " + t);
       t.start();
       }
   public void run(){
       try{
           for(int i=5;i>=1;i--){
               System.out.println("Thread anak : "+i);
               Thread.sleep(500);
           }
       }catch (InterruptedException ie){
       System.out.println("Thread anak diinterupsi");
   }
       System.out.println("Thread anak selesai");
   }
   }
public class Main {
   /**
    * @param args the command line arguments
    */
  
  
   public static void main(String[] args) {
       // TODO code application logic here
       new thethread();
       System.out.println("Thread utama mulai");
       try{
           for(int i=0;i<10;i++)
               System.out.println("Thread utama : " + (i+1));
               Thread.sleep(1000);
       }
   catch (InterruptedException ie){
       System.out.println("Thread utama diinterupsi");
   }
   System.out.println("Thread utama selesai");
  
   }   
      
}
Java Thread
Langganan:
Posting Komentar (Atom)



Tidak ada komentar:
Posting Komentar