Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

I don't understand this thread behavior?

 
Tanakorn Numrubporn
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Report post to moderator
This is my code for solve the K&B Book in Threads chapter.



the output is:
100a, 100b, 100c print continuously.

The purpose of this program is use three thread to go to print letter 100 letters and each thread increase one letter such as first-thead's letter is "a" and second-thread's letter is "b" and so on.

In this code I send "a" to the 'HimThread' constructor, why don't the HimThread instance reset the 'sb' variable to "a" but continue increase letter to "b" in later thread and "c" in third thread.

Thank you

ps# sorry for my idiot because I write this code by myself but I don't understand it.
 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks Marc

 
Tanakorn Numrubporn
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'm confusing because my First post is link to the "mix old and new generics" topics and not refer to my message. So, then, I repost it, and now the first post detail is in the second post topic and the second post detail is in the first post topic.

Sorry for messing this forum content.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Report post to moderator
Well I'm not sure what happened here - looks like one of our occasional race conditions. Unfortunately it seems that Anthony's original post, and Mar,'s reply, have been lost. And Tanakorn has now reposted his post here where it's more clear. So I guess it's best now to just close this. Sorry for the confusion.
[ January 10, 2007: Message edited by: Jim Yingst ]
 
    Bookmark Topic Watch Topic
  • New Topic