• Post Reply Bookmark Topic Watch Topic
  • New Topic

synchronization in thread  RSS feed

 
ami gu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello, folks. I am trying to synchronize two thread which can both sell tickets. The follwoing is my code:



Then I got my result. It is just a single thread which is trying to "sell" the 100 tickets. However,if I change the order of main method like the following:



I got two threads running which are trying to "sell" the tickets. I do not really know what is happening here. Can anyone let me know what is going on with it? Does it make any difference where I put "st.b = true;" ?

Thank you!
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"ami gu",

I have asked you this before (on June 6th), please read your private messages regarding an important question. I would advise you to head this warning.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!