Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package intropackage;
- public class Driver {
- public static void main(String[] args) throws InterruptedException {
- myThread thread = new myThread();
- thread.start();
- thread.interrupt(); //Thread.currentThread() causes interruption to myThread
- System.out.println("END OF MAIN THREAD");
- }
- }
- public class myThread extends Thread {
- @Override
- public void run() {
- try {
- for(int i=0;i<10;i++)
- {
- System.out.println("CHILD THREAD-"+i);
- Thread.sleep(1000);
- }
- } catch (InterruptedException e) {
- System.out.println("I am Interrupted ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement