hi please give me a solution for the below problem
I need d following output :
in AAA thread
in BBB thread
in AAA thread
in BBB thread
in AAA thread
in BBB thread
help me
This message was edited 2 times. Last update was at by Bear Bibeault
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32421
posted
0
Welcome to JavaRanch.
If you need a certain sequence of events you shouldn't use concurrency - it's up to the JVM how independent threads are scheduled. A combination of wait() and notify() calls can probably achieve what you're asking, but again - if the order of execution is fixed, what's the point of using two threads?
In the future, please UseCodeTags. It's unnecessarily hard to read the code otherwise, making it less likely that people will bother to do so. I have added them for you here. Also please UseAMeaningfulSubjectLine and KeepItDown.
This message was edited 2 times. Last update was at by Ulf Dittmer
"sun son", please check your private messages for an important administrative matter. Again.
Michal Bogdal
Greenhorn
Joined: Mar 04, 2010
Posts: 3
posted
0
Hi, Thomas. Could you say something more about your doubts? Both threads use synchronized block on the same common object "director", so only one thread can be inside this block at a time. Besides the methods in "Director" class needn't be synchronized, becouse you call them from synchronized block.
Bye