JAVA LAB 9.docx
JAVA LAB 9.docx
MULTITHREADING
Vibhuti purohit
22MIM10029
CODE:
public class Taskthreaddemo
{
public static void main(String[] args) {
try {
thread1.start();
thread2.start();
thread3.start();
} catch (Exception e)
{ System.out.println("Thread " + "interrupted.
");
}
}
}
class PrintChar implements
Runnable{ private char chartoprint;
private int times;
}
}
}
public void run(){
for (int i=1; i<= lastNum; i++)
{ System.out.println(" "+ i);
}
}
}
OUPUT 1:
OUTPUT 2:
OUTPUT 3:
try {
thread1.start();
thread1.sleep(1000);
thread2.start();
thread3.start();
} catch (Exception e)
{ System.out.println("Thread " + "interrupted.
");
}
}
class PrintChar implements
Runnable{ private char chartoprint;
private int times;
}
}
}
public void run(){
for (int i=1; i<= lastNum; i++)
{ System.out.println(" "+ i);
}
}
}