Multi.threadC.join();
System.out.println(MyMain.time() + "threadE\t\tJoined
threadC");
InterruptibleThread.sleep(2000);
System.out.println(MyMain.time() + "threadE\t\tJoining
threadD");
Multi.threadD.join();
System.out.println(MyMain.time() + "threadE\t\tJoined
threadD");
InterruptibleThread.sleep(1000);
System.out.println(MyMain.time() + "threadE\t\tExiting ");
} catch (InterruptedException e) {
System.out.println("CAN'T GET HERE.");
}
}
}
All code examples in this topic are available from the Web (see Code Examples). They are all as
nearly identical to the same programs written in C from Multithreaded Programming with
PThreads as we could make them. In a few cases the Java code is a bit constrained because of this,
but there are no significant issues.
exactly when we expect them to.
bil@cloudbase[264]: java Multi
Time Thread
Event
==== ======
=====
1000 threadMain
Started
1001 threadMain
Created threadA
1001 threadA
Starting...
1002 threadMain
Created threadC
1002 threadC
Starting...
1002 threadA
Created threadD
1002 threadD
Starting...
1003 threadD
Created threadE
1003 threadE
Starting...
1004 threadMain
Cancelling threadD
1004 threadD
Interrupted. Exiting
1004 threadC
Joining threadMain
1005 threadMain
Exiting
1005 threadC
Joined threadMain
1005 threadA
Exiting
1006 threadC
Created threadB
1006 threadB
Starting...
1006 threadE
Joining threadA
1006 threadE
Joined threadA
1008 threadE
Joining threadC
1010 threadC
Exiting
1010 threadE
Joined threadC
1010 threadB
Exiting
1012 threadE
Joining threadD
1012 threadE
Joined threadD
1013 threadE
Exiting
bil@cloudbase[265]:
Search WWH :