• Post Reply Bookmark Topic Watch Topic
  • New Topic

thread  RSS feed

 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1: objects are created.
2: objects are created.
4: objects are created.
4: objects are created.
5: objects are created.
6: objects are created.
7: objects are created.
8: objects are created.
9: objects are created.
10: objects are created.


why it doesn't print 2,4,6,8,10,12,14,16,18,20 ?

synchronized(st){
st.count=count++;
}
this block wont work ?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't about threading or synchronization, it is about poor use of the post increment. See http://www.coderanch.com/how-to/java/PostIncrementOperatorAndAssignment
 
meeta gaur
Ranch Hand
Posts: 305
Notepad Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!