Skip to content

Commit fa218af

Browse files
authored
Update ProduConsum.java to add comments
1 parent 5cb1d0a commit fa218af

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

ProduConsum.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public static void main(String []args)throws InterruptedException
1818

1919
Thread ct=new Thread(c);
2020

21-
pt.start();
21+
pt.start(); // Thread execution begins
2222

2323
ct.start();
2424

25-
pt.join();
25+
pt.join(); // Current thread execution is paused, until specified thread is dead.
2626

2727
ct.join();
2828

@@ -84,7 +84,7 @@ synchronized void get()
8484
if(!valueset)
8585
{
8686
try {
87-
wait();
87+
wait(); // Current thread will wait until notify() is invoked
8888

8989
} catch (InterruptedException e) {
9090

@@ -95,7 +95,7 @@ synchronized void get()
9595

9696
System.out.println("Got"+" "+this.n);
9797

98-
notify();
98+
notify(); // Wakes up thread that is waiting on Object's monitor
9999
}
100100
synchronized void set(int n)
101101
{
@@ -116,4 +116,4 @@ synchronized void set(int n)
116116

117117
notify();
118118
}
119-
}
119+
}

0 commit comments

Comments
 (0)