aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Does this program fulfill Exercise 9-2 in K and B SCJP study guide? 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 "Does this program fulfill Exercise 9-2 in K and B SCJP study guide?" Watch "Does this program fulfill Exercise 9-2 in K and B SCJP study guide?" New topic
Author

Does this program fulfill Exercise 9-2 in K and B SCJP study guide?

Ted North
Ranch Hand

Joined: Jan 02, 2012
Posts: 193
    
    1



Requirements are:

1. create a class and extend the Thread class.
2. Override the run() method of Thread. This is where the synchronized block of code will go.
3. For our three thread objects to share the same object, we will need to create a constructor that accepts a StringBuffer object in the argument.
4. The synchronized block of code will obtain a lock on the StringBuffer object from step 3
5. Within the block, output the StringBuffer 100 times (i only output 10 times so i could read all the output in the shell) and then increment the letter in the StringBuffer. You can check
Chapter 6 for StringBuffer methods that will help with this.
6. Finally, in the main() method, create a single StringBuffer object using the letter A, then create three instances of our class and start all three of them (i also named the threads so the output makes more sense to me).

i humbly offer this hilarious picture for the end-users that would appreciate it; all others please do not look below this sentence.

Ted North
Ranch Hand

Joined: Jan 02, 2012
Posts: 193
    
    1

bump

- does no one have any thoughts on this?

- java_ranch its time to saddle up and un-holster that keyboard.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does this program fulfill Exercise 9-2 in K and B SCJP study guide?