Here is a snippet of code
public class ITC3 extends Thread { private ITC4 it; public ITC3(ITC4 it){ this.it = it; } public static void main(String[] args) { ITC4 itr = new ITC4(); System.out.println("name is:" + itr.getName()); ITC3 i = new ITC3(itr); ITC3 ii = new ITC3(itr); i.start(); ii.start();
Output
Output: Waiting - Thread-1 Waiting - Thread-2 Sleeping : Thread[Thread-0,5,main] Notified Thread-1 Notified Thread-2
In this, all threads are notified. I can not understand the whole result in this matter.
- Why are all threads receiving notification?
- Why Sleeping prints `Thread [Thread-0.5, main]
- Pretty lost in all the work of the program.
Any pointers would be helpful.
Thanks.
source share