Java Threads

Errata for Java Threads

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page 30
1st paragraph

"as we discuss Chapter 12" at the end of the paragraph should read "as we discuss in Chapter 12".

Anonymous   
Printed
Page 30
last paragraph

The author states that - "It's possible for the main thread to call the interrupt() method just after the RandomCharacterGenerator has called the isInterrupted() method. The character-reading thread still executes the sleep() method, which won't be interrupted ( since the main thread has already executed the interrupt() method). This is another example of a race consition that we solve in the next chapter." However if main executes the interrupt() method after RandomCharacterGenerator has called the isInterrupted() method, it's interrupted status will be set. So when the character reading thread executes the Sleep method, it doesn't go to sleep but immediately throws InterruptedException. So although it won't be interrupted, it still throws InterruptedException. I think this point could be added because although the race condition still applies, the description is ambiguous. Thanks.. Chan.

Note from the Author or Editor:
Reword this paragraph: It's possible for the main thread to call the interrupt() method just after the RandomCharacterGenerator has called the isInterrupted() method. The character-reading thread still executes the sleep() method, which won't be interrupted ( since the main thread has already executed the interrupt() method). This is another example of a race consition that we solve in the next chapter. to this: It's possible for the main thread to call the interrupt() method while the RandomCharacterGenerator is executing the isInterrupted() method. Depending on the timing, the character-reading thread could end up executing the sleep() method, which won't be interrupted ( since the main thread has already executed the interrupt() method). This is another example of a race condition that we solve in the next chapter

ChanAg  Jun 29, 2013 
Printed
Page 42
-1

Similarly, every time the variable is written, the value must be stored in main memory. Since these operations are atomic, we can avoid the race condition in our example by marking our done flag as volatile. -> Similarly, every time the variable is written, the value must be stored in main memory. Furthermore, Java specifies that the load and store operations are atomic for volatile variables, even for long and double variables. Hence, we can avoid the race condition in our example by marking our done flag as volatile. ########################################

Anonymous    Mar 01, 2007
Printed
Page 47
3rd paragraph

"implemenation" should be "implementation"

Anonymous  Mar 16, 2009 
Printed
Page 59
+5

The isHeldByCurrentThread() method is used to determine if the thread is owned by the current thread, -> The isHeldByCurrentThread() method is used to determine if this lock is owned by the current thread, ########################################

Anonymous    Mar 01, 2007
Printed
Page 82
-2

We've already seen that in one case the answer is yes: you can use the volatile keyword for an instance variable (other than a double or long). -> We've already seen that in one case the answer is yes: you can use the volatile keyword for an instance variable. ########################################

Anonymous    Mar 01, 2007
Printed
Page 85
first thread execution sequence, last line

Thread1: Set currentScore == 0 -> Thread1: Set currentScore = 0 ########################################

Anonymous    Mar 01, 2007
Printed
Page 85
second thread execution sequence, line 3

Thread2: See if currentScore == 0 -> Thread2: See if currentScore = 0 ########################################

Anonymous    Mar 01, 2007
Printed
Page 86
4th para

"treatement" should be treatment.

Anonymous  Mar 16, 2009 
Printed
Page 87
+2

Of course, the balance is very one sided; volatile variables can be safely used only for a single load or store operation and can't be applied to long or double variables. These restrictions make the use of volatile variables uncommon. -> Of course, the balance is very one sided; volatile variables can be safely used only for a single load or store operation. This restriction makes the use of volatile variables uncommon. ########################################

Anonymous    Mar 01, 2007
Printed
Page 111
under "Critical Section"

A critical section is a synchronized method or block. Critical sections do not nest like synchronized methods or blocks. -> A critical section is a synchronized method or block. It is provided by Windows as a lightweight version of a lock. ########################################

Anonymous    Mar 01, 2007
Printed
Page 112
+3

The Semaphore class keeps tracks of... -> The Semaphore class keeps track of... ########################################

Anonymous    Mar 01, 2007
Printed
Page 129
The newCondition() method, does

public Condition newCondition( ) { return new DeadlockDetectingCondition(this); -> public Condition newCondition( ) { return new DeadlockDetectingCondition(this, super.newCondition( )); ########################################

Anonymous    Mar 01, 2007
Printed
Page 142
Summary table, row 1, column 1

Deadlock-detecting Lock -> Deadlock-detecting Lock (example 1) ########################################

Anonymous    Mar 01, 2007
Printed
Page 142
Summary table, row 2, column 1

Alternate Deadlock-detecting Lock -> Alternate Deadlock-detecting Lock (example 2) ########################################

Anonymous    Mar 01, 2007
Printed
Page 142
Summary table, row 1, column 2

javathreads.examples.ch06.example1.DeadlockDetectingLock -> javathreads.examples.ch06.DeadlockDetectingLock ########################################

Anonymous    Mar 01, 2007
Printed
Page 142
Summary table, row 2, column 2

javathreads.examples.ch06.example2.AlternateDeadlockDetectingLock -> javathreads.examples.ch06.AlternateDeadlockDetectingLock ########################################

Anonymous    Mar 01, 2007
Printed
Page 149
run() method at bottom of page

public void run( ) { // Simulate connecting to server for (int i = 0; i < stateMessages.length; i++) { setText(stateMessages[i]); try { Thread.sleep(5 * 1000); } catch (InterruptedException ie) {} if (Thread.currentThread( ).isInterrupted( )) return; } -> public void run( ) { // Simulate connecting to server for (int i = 0; i < stateMessages.length; i++) { setText(stateMessages[i]); try { Thread.sleep(5 * 1000); } catch (InterruptedException ie) {} if (Thread.currentThread( ).isInterrupted( )) return; } ########################################

Anonymous    Mar 01, 2007
Printed
Page 161-162
code at bottom of page

public void fireNewCharacter(CharacterSource source, int c) { CharacterEvent ce = new CharacterEvent(source, c); Enumeration e; synchronized(listeners) { e = listeners.elements( ); while (e.hasMoreElements( )) { ((CharacterListener) e.nextElement( )).newCharacter(ce); } } } -> public void fireNewCharacter(CharacterSource source, int c) { CharacterEvent ce = new CharacterEvent(source, c); Enumeration e; synchronized(listeners) { e = listeners.elements( ); while (e.hasMoreElements( )) { ((CharacterListener) e.nextElement( )).newCharacter(ce); } } } ########################################

Anonymous    Mar 01, 2007
Printed
Page 196
Second Last Para

In the second last paragraph, the Callable interface is described. The method call is declared as follows. public <V> call() throws Exception; It needs to be changed as - public V call() throws Exception; as V here is the return type. Chan.

Note from the Author or Editor:
On page 196, change the line reading public <V> call() throws Exception; to public V call() throws Exception;

Chan  Aug 02, 2013 
Printed
Page 217
checkLicense() method in middle of page

// If we got a result, we know that the license has expired JOptionPane.showMessageDialog(null, "Evaluation time period has expired", "Expired", JOptionPane.INFORMATION_MESSAGE); -> // If we got a result, we know that the license has expired JOptionPane.showMessageDialog(null, "Evaluation time period has expired", "Expired", JOptionPane.INFORMATION_MESSAGE); ########################################

Anonymous    Mar 01, 2007
Printed
Page 228
first full para

"simulataneous" should be "simultaneous"

Anonymous  Mar 16, 2009 
Printed
Page 231
last para

"accomodate" should be "accommodate"

Anonymous  Mar 16, 2009 
Printed
Page 235
handleClient() method at bottom of page

protected void handleClient(SelectionKey key) throws IOException { SocketChannel sc = (SocketChannel) key.channel( ); ClientInfo ci = (ClientInfo) allClients.get(sc); -> protected void handleClient(SelectionKey key) throws IOException { SocketChannel sc = (SocketChannel) key.channel( ); ClientInfo ci = (ClientInfo) allClients.get(sc); ########################################

Anonymous    Mar 01, 2007
Printed
Page 307
Summary table, row 2, column 1 (example 4)

Table Generator (Handling reduction variables) -> Table Generator (Handling storeback variables) ########################################

Anonymous    Mar 01, 2007