Search This Blog

25 July, 2012





MultiThreading Best example.....




package DemoWork;

class Demo implements Runnable{
    int p;
    Thread th;
    public Demo(int i,String threadName) {
            p=i;
            th=new Thread(this,threadName);
            th.start();
    }
    void process(){
        for(int j=1;j<=10;j++){
            int temp=p*j;
            System.out.print(" "+temp);
        }
        System.out.println();

    }

    public void run(){
        System.out.print(th.getName()+" is starting");
      process();

    }

}
public class ThreadRelatedAssign {
  public static void main(String[] m){
    new Demo(5,"I-Thread");
    new Demo(10,"II-Thread");
    new Demo(50,"III-Thread");


 }
}

Meetme@