wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Excercise 9-2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Excercise 9-2" Watch "Excercise 9-2" New topic
Author

Excercise 9-2

Glen Iris
Ranch Hand

Joined: Jul 13, 2011
Posts: 164

I am trying to synchronize a block of code as detailed on page 738/739.

I cannot figure out how to access the String that I pass to my MyThreaddy method on lines 9,10 and 11 of the below code.

I wish to access the letters 'a','b' or 'c', depending on the thread on line 33/34.


I hope somebody can help me. Thank you :-)


OCPJP 6, OCMJD
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18520
    
  40

Glen Iris wrote:I am trying to synchronize a block of code as detailed on page 738/739.

I cannot figure out how to access the String that I pass to my MyThreaddy method on lines 9,10 and 11 of the below code.

I wish to access the letters 'a','b' or 'c', depending on the thread on line 33/34.


I hope somebody can help me. Thank you :-)



The second parameter to the constructor (in lines 9, 10, and 11) is for the name of the thread ... which you changed in line 13, 14,and 15.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Glen Iris
Ranch Hand

Joined: Jul 13, 2011
Posts: 164

Thank you Henry.
 
 
subject: Excercise 9-2
 
Similar Threads
Threads and synchronisation
How to make one thread die before another thread
Problem with excirse 9-2
Syncronizing variables or classes - Exercise 9-2
Threads: synchronizing a block of code (K&B 1.5)