Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

K&B Thread chapter: A couple of questions

 
Johnny Hunter
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic