This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes K&B Thread chapter: A couple of questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "K&B Thread chapter: A couple of questions" Watch "K&B Thread chapter: A couple of questions" New topic
Author

K&B Thread chapter: A couple of questions

Johnny Hunter
Ranch Hand

Joined: Jul 15, 2004
Posts: 37
1) Thread contructors are shown to use ThreadGroups. Do I need to know about thread groups for the exam?
2) In the Two-Minute Drill, it is stated that: "Only one thread can be running at a time, although many threads may be in the runnable state." That doesn't sound right. Most JVM implement java threads as native threads causing the OS scheduler to run multiple threads concurrently if the JVM is hosted on a multi CPU box.

Thanks for your help.


Johnny Hunter
SCJP 1.4
Johnny Hunter
Ranch Hand

Joined: Jul 15, 2004
Posts: 37
This code:
class A implements Runnable {

public void run() { System.out.println("run Lola run"); }

public static void main(String args[]) {
Thread t = new Thread(new A());
t.start();
t.start(); // should throw a runtime exception
}
}


doesn't throw a runtime exception (at least on OS X) as it is stipulated it would do on page 536 of K&B.
[ July 16, 2004: Message edited by: Next Stepguy ]
Johnny Hunter
Ranch Hand

Joined: Jul 15, 2004
Posts: 37
Dissecting the Thread chapter:
The code at the bottom of page 513 for the Join example is partially wrong; it should include a try/catch (InterruptedException) around the join (or at least mention that join() needs it...)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: K&B Thread chapter: A couple of questions