wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes I don't understand this thread behavior? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic
Author

I don't understand this thread behavior?

Tanakorn Numrubporn
Ranch Hand

Joined: Dec 11, 2006
Posts: 81
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

Joined: Aug 09, 2004
Posts: 342
Thanks Marc



SCJP 5
Tanakorn Numrubporn
Ranch Hand

Joined: Dec 11, 2006
Posts: 81
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

Joined: Jan 30, 2000
Posts: 18671
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 ]

"I'm not back." - Bill Harding, Twister
 
 
subject: I don't understand this thread behavior?