Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //main
- package create3;
- public class Create3 {
- public static void main(String[] args) {
- NumPrinter np1 = new NumPrinter();
- NumPrinter np2 = new NumPrinter();
- NumPrinter np3 = new NumPrinter();
- np1.start();
- try{np1.join();} catch(Exception ex){
- np2.start();
- np3.start();
- }
- }
- }
- //2nd class
- package create3;
- public class NumPrinter extends Thread{
- @Override
- public void run(){
- for(int i= 1;i<=10;i++){
- try{Thread.sleep(1000);} catch(Exception ex){};
- System.out.println(i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment