Nitesh Kant wrote:It looks like your assignment so i will not give you the code!
The following are my inputs:
The synchronized blocks in main are not required because no two threads execute the main method at any time. The synchronized methods in T1 are not required as no two threads execute those methods. I dont see a code for "pause". You would require wait-notify for this. The monitor for wait-notify can be an arbitrary object instance. You do not need a new class for it.
Not sure why you do this:
Let me know if the above is not clear.
Praveen Seluka wrote:Hi
I could not understand the requirement clearly.
Can you explain what is the expected behavior .
what do you mean by
Stop the thread from T1
Wait for 5 seconds
Stop the thread from T2
If you can provide requirements clearly I will give a try.
Whether t1 and t2 should interleave or something
expected output or a dry-run please