Professional Documents
Culture Documents
Create two (2) threads named by the user. Display their various states using getState( ).
In the main method:
Answer:
Codes:
import java.util.Scanner;
thread1.setName(tn1);
thread2.setName(tn2);
try {
thread1.sleep(500);
thread2.sleep(500);
System.out.println("\n\nAfter sleep...");
} catch(InterruptedException e) {
}
}
}
Output: