By Developers, For Developers

Historical errata for Programming Concurrency on the JVM

PDF PgPaper PgTypeDescriptionFixed onComments
32TYPO

From the “Division of Labour” pdf excerpt, in the “Divide the Number of Threads” section, the last full paragraph on this page contains the sentence “If they spend less time begin blocked, that is they’re computation intensive, then you should have fewer threads, but no less than the number of cores.”.

It should read “…spend less time BEING blocked…”

2011-05-27
21TYPO

Deadlocd instead of deadlock.

2011-05-27
22TYPO

“Something tlike this”

2011-05-27
31TYPO

“the effort to determine if a number is primes” -> prime

2011-05-27
247SUGGEST

In the onReceive method, it would be more idiomatic to use a case statement.

case message; when FetchTotalSize …

2011-05-27
104TYPO

First paragraph - “… It this succeeded…” should be “… If this succeeded…”

2011-05-27
44TYPO

“a rather 1.5 times speedup” -> a rather meager speedup? subtle speedup? slight?

2011-05-27
48TYPO

“once you fully eliminating”-> eliminate

2011-05-27
48TYPO

“there’s no issue of visibility and crossing memory barrier” -> crossing THE memory barrier?

2011-05-27
51TYPO

“You have to ensure that your code crosses the memory barrier at appropriate time,” -> at THE appropriate time

2011-05-27
74ERROR

The ConcurrentTotalFileSizeWQueue blocks forever when scanning complicated directories, such as “c:/windows”.

Setting the thread pool to a lower value, such as 10, makes it complete.

My environment:
java version “1.6.0_24”
Java™ SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot™ Client VM (build 19.1-b02, mixed mode, sharing)

Windows 7 SP1 64-bit on quad-core i7 920.

2011-05-27
100TYPO

“His vision was primarily message passing and wanted to get rid of data” -> and HE wanted to get rid of data

2011-05-27
39ERROR

Loving the book.

I don’t think pool.invokeAll works as described here. When it returns, all the work is done.

val futures = pool.invokeAll(callables)
futures.foreach(f => log.info(f.isDone.toString))

This logs all “true”s, even though each callable takes one second to process.

CompletionService can be used with a pool to fetch work out as it finishes.

daveb@davebsoft.com @dcbriccetti

2011-05-27
181TYPO

In last paragraph of page, missing “is”:

Oh wait, there one other detail,

should be, I think:

Oh wait, there is one other detail,

2011-05-27
213TYPO

2nd to last paragraph:

Transactors also provides handles to run some code before a …

should be “provide” instead of “provides”

2011-05-27
251TYPO

Doing it right can help YOU safely reach your… instead of Doing it right can help safely reach your…

2011-05-27
24TYPO

… that implicitly crosses thememory barrier…

must be

… that implicitly cross thememory barrier…

2011-05-27
30TYPO

If they spend less time begin blocked …
must be
If they spend less time being blocked …

2011-05-27
9SUGGEST

“Moore’s Law…. ” The sentence is too long. Split it before the, “and to”

2011-05-27
9SUGGEST

“how critical the travel time is [….], and so on” -> “how critical the travel time […], and so on, are”

2011-05-27
10SUGGEST

“this book will not help you to learn”: doubled “help to learn” in the next sentence.

2011-05-27
11SUGGEST

“What’s in this book?
The rest of this book will”

Starting with “The rest of this book” doesn’t match the headline.

2011-05-27
12TYPO

“The word Java today stands more for the platform than for the language.” The sentence is difficult to understand

2011-05-27
13TYPO

“extra effort to keep the syntax of these language to a minimal” -> languages

2011-05-27
13SUGGEST

“Where there is a choice” -> Sentence too long and difficult

2011-05-27
13TYPO

“The following is the version of languages” -> The following are the versions of the languages

2011-05-27
14SUGGEST

“Go ahead and download the entire source code for this book from the website for this book” -> from its website

2011-05-27
14TYPO

“However, any errors you find in this book is entirely a” -> are entirely

2011-05-27
17SUGGEST

“flows of execution, a single” Use a : before “a single”

2011-05-27
18TYPO

“I want to time an event and so decided” -> wanted (because of decided)

2011-05-27
18SUGGEST

“stopwatch application, we can” -> colon before “we can”

2011-05-27
18ERROR

Don’t ignore the InterruptedException without any note.

2011-05-27
18SUGGEST

“event handler actionPerformed( ), but it” Why “but”?

2011-05-27
19SUGGEST

Explain “main event thread”. Not everyone is familiar with UI programming.

2011-05-27
20TYPO

“We need to present” -> needed

2011-05-27
21SUGGEST

“timeout. You design your solution” Leave out the “you”

2011-05-27
22SUGGEST

TimeUnit.SECONDS.sleep(2) could make the link to the mentioned “2 seconds” instead of sleep(2000)

2011-05-27
24TYPO

“implicitly crosses the” -> cross

2011-05-27
24SUGGEST

“synchronized and volatile force that the changes are globally
visible on a timely basis,” -> The synchronized and volatile keywords force the changes to be globally visible…

2011-05-27
27ERROR

Use the order of keywords as mentioned in JLS 8.3.1 Field Modifiers > private static volatile and JLS 8.4.3
public static synchronized

2011-05-27
27SUGGEST

The last sentence is not easy to understand.

2011-05-27
38SUGGEST

I agree with Dave. The description does not match the behavior of the invokeAll method:
private static void invokeAll() throws InterruptedException,
\t\tExecutionException {
\tExecutorService threadPool = Executors.newFixedThreadPool(5);
\tList<Callable> lst = new ArrayList<Callable>();
\tfor (int i = 0; i < 10; i) {
\t\tlst.add(new Callable() {
\t\t\t@Override
\t\t\tpublic Boolean call() throws Exception {
\t\t\t\tTimeUnit.SECONDS.sleep(5);
\t\t\t\tSystem.out.println(“completed”);
\t\t\t\treturn Boolean.TRUE;
\t\t\t}
\t\t});
\t}

\tSystem.out.println(“Invoking”);
\tList<Future> futures = threadPool.invokeAll(lst);
\tSystem.out.println(“Finished”);

\tfor (Future future : futures) {
\t\tSystem.out.println(future.get());
\t}
}
Which will print “Invoking”,10x “Completed” and “Finished”

The described behavior is achieved when using submit
private static void invoke() throws InterruptedException,
\t\tExecutionException {
\tExecutorService threadPool = Executors.newFixedThreadPool(5);
\tSystem.out.println(“Submitting”);
\tList<Future> futures = new ArrayList<Future>();
\tfor (int i = 0; i < 10; i) {
\t\tfutures.add(threadPool.submit(new Callable() {
\t\t\t@Override
\t\t\tpublic Boolean call() throws Exception {
\t\t\t\tTimeUnit.SECONDS.sleep(5);
\t\t\t\tSystem.out.println(“completed”);
\t\t\t\treturn Boolean.TRUE;
\t\t\t}
\t\t}));
\t}
\tSystem.out.println(“Submitted”);

\tfor (Future future : futures) {
\t\tSystem.out.println(future.get());
\t}
\tSystem.out.println(“Finished”);
}

2011-05-27
31TYPO

“more time blocked” -> more time beeing blocked

2011-05-27
31SUGGEST

“You can try to guess it. Or you can also use profiling” -> You can try to guess it or you can use profiling

2011-05-27
31TYPO

“TheRE would, however, …”

2011-05-27
31TYPO

“One, this is hard, it would” -> First, …

2011-05-27
32SUGGEST

First sentences should be made more clear on this page

2011-05-27
32SUGGEST

Move the Footnote to the intro, because there’s also an unhandled exception some pages before this one.

2011-05-27
33TYPO

“took for this operation” -> took for completing this operation

2011-05-27
34TYPO

“to the wait she had” why “she”?

2011-05-27
35TYPO

“There are now two challenges.” -> two challenges now

2011-05-27
36SUGGEST

Hmm.. synchronized is not a bad keyword at all. As JCIP states it might be favoured for future optimizations because it’s build into the languages whereas a Lock is only a class.

2011-05-27
100TYPO

" What’s worst, you get no" —> “What’s WORSE”?

2011-05-27
48TYPO

… once you fully eliminating shared mutable state
must be
… once you have fully eliminated shared mutable state

2011-05-27
51TYPO

… that’s shared between threads are immutable
must be
… that’s shared between threads is immutable

2011-05-27
46TYPO

“The finer we divide the problem, more likely” the more likely it is that there will be enough sliceS

2011-05-27
50TYPO

“Your objects encapsulate
state and their methods help transition between select valid states” -> selected?

2011-05-27
52TYPO

“Also this approach involves quite a bit of blocking of threads,” -> This approach also involves

2011-05-27
54TYPO

“The data we have to dealing with” -> have to deal with

2011-05-27
56TYPO

“You can’t get away
simply changing the root of a tree” -> by simply changig

2011-05-27
59TYPO

In the listing: isolated mutability (lower case instead of upper)

2011-05-27
54SUGGEST

The short paragraph about the persistent data structures seems a bit out of place here. The information is too little (for me) to understand. Maybe refer to a more dedicated section of the book, or go in more depth here.

2011-05-27
72SUGGEST

Why do you use the while-loop with compareAndSet instead of addAndGet?

2011-05-27
82SUGGEST

Provide a reference to JCIP lock ordering in the sorting the Accounts explanation.

2011-05-27
81SUGGEST

“There’s even a variation that allows you to interrupt a
thread while it’s waiting for a lock.” “You may even have your wait interrupted quite easily.” Doubled with very similar sentences.

2011-05-27
81TYPO

“to ensure A proper unlock” or “to ensure proper unlockING”

2011-05-27
89ERROR

The Timer class itself uses a dedicated Thread. Using an unshared timer won’t help..

Using a Timer might also introduce another concurrency issue if the replenish method get’s more complicated and throws an exception, this will cause the scheduling Thread to die and no other thread will take it’s place. This will render the schedule method a no-op.

The Timer class also invokes the Thread start in it’s constructor… at least in the JDK implementation which I see here.

2011-05-27
92ERROR

“Access to final variables don’t need to cross memory barriers, since they don’t change and cached values
are as good as the one in memory.”
This is only true for immutable objects and not for final variables in general.

2011-05-27
92TYPO

“Let’s take a look at the modified code first before we discuss further.” -> discuss it

2011-05-27
100TYPO

“We’ve been lead down the path of imperative”
“This largely lead us towards encapsulating and mutating”
-> both have to be “led” instaed of lead

2011-05-27
101TYPO

“the current OO paradigm models it.” it??

2011-05-27
101TYPO

“Separate identity from it immutable state” from its

2011-05-27
118TYPO

“Spend some time to play” A space is missing.

2011-05-27
132SUGGEST

Use the STMUtils Java class instead of “akka.stm.StmUtil$class.retry” which looks very ugly in Java.

2011-05-27
133TYPO

“StmUnit$class” 2 times, should be StmUtil$class

2011-05-27
149TYPO

“I report here the output on my system for the /etc and /usr
directories.” -> I report the output … here.

2011-05-27
148ERROR

Status Code 0 shouldn’t be used for abnormal termination in System.exit

2011-05-27
26SUGGEST

Suggest “remember Mom always advised us…” instead of “remember mom always advised us…”.

2011-05-27
26TYPO

“In fact, significant number of concurrent Java apps…”. Put “a” in front of “significant” to fix.

2011-05-27
26TYPO

“Now suppose you have a final (immutable) field to an immutable instance…” should be “Now suppose you have a final (immutable) field referring to an immutable instance…”

2011-05-27
152TYPO

“with access pattern appropriate for STM.” -> “an access pattern” or access patterns ?

2011-05-27
175TYPO

“to support asynchrony and efficient messaging.” Isn’t it asynchronous?

2011-05-27
180ERROR

“The delay introduced keeps the program alive while the actor responds to messages—the actors run in a non-daemon thread pool and will not keep your JVM alive if all daemon threads are gone. Take it for a ride to see the output.”

In Java there are User-Threads and Deamon Threads, where a User-Thread must be stopped before the JVM may terminate, whereas Deamon Threads don’t keep the JVM running, but are killed if all User Threads were stopped and the JVM terminates. Therefore I think the description given here is wrong. Actor-Threads are deamon threads.

2011-05-27
183TYPO

“works well with pattern matching” -> work well

2011-05-27
186TYPO

“to see if response is available” -> if a response

2011-05-27
186TYPO

“method as call to these methods” -> as calls to

2011-05-27
186TYPO

“Exercise caustion when” -> Exercise caution

2011-05-27
200TYPO

“as we translation” -> as we translate

2011-05-27
209TYPO

“implementation for the isDefined()” -> in the code it’s called isDefinedAt()

2011-05-27
211TYPO

“are simply translation” -> are simply translations OR are simply translated

2011-05-27
214TYPO

“getting access to the transaction Coordinated object” -> to the transaction’s Cooordinated object

2011-05-27
216TYPO

Set coordinations = new java.util.HashSet();

The Set is missing the generic type parameter SendTo

2011-05-27
234TYPO

“and allow you to configure various parameters like fairness of thread affinity” -> and allows

2011-05-27
236TYPO

“in response to the messages send.” -> sent

2011-05-27
237TYPO

“accepts a closure that is be called” -> is to be called

2011-05-27
248TYPO

“UntypedActorprovides a few flavors of” missing space before provides

2011-05-27
248SUGGEST

“Let’s take this JRuby version of file size program for a ride across the
/usr directory.
Total size is 3793911517
Time taken is 14.505133”

Explain the time difference of the JRuby version compared to the other implementations.

2011-05-27
184TYPO

“This method return a Future of an…” -> “This method returns a Future of an…”

2011-05-27
197TYPO

In next-to-last paragraph on page, the 2 instances of “FileToProcesss” should be “FileProcessors”.

2011-05-27
208TYPO

“The proxy used by the users of typed actors convert method calls to messages.” -> “The proxy used by the users of typed actors converts method calls to messages.”

2011-05-27
230TYPO

This is two sentences separated by a comma: “We did not modify the actor itself, the new state we return will become…”
I’m not sure what was actually intended, so can’t suggest a correction.

2011-05-27
54TYPO

5th paragraph/2nd line: to organize or compose these sequence of operations -> to organize or compose this sequence of operations

2011-05-27
56SUGGEST

That’s exactly what Phil Bagwell -> Phil who?
This may be obvious to many, but maybe there should be a note at the bottom of the page. Something like 3. Phil Bagwell: bla, bla.

2011-05-27
56SUGGEST

2nd paragraph: Removals from the head… -> May need to explain why this removal method doesn’t affected immutability. It isn’t clear if you haven’t seen/used these lists before.

2011-05-27
57SUGGEST

Rich Hickey used a… -> Rich who?
This may be obvious to many, but maybe there should be a note at the bottom of the page. Something like 4. Rich Hickey: bla, bla.(Like in p56)

2011-05-27
58SUGGEST

Rather than having to copy all nine elements, we only had to copy three nodes -> May be you can identify which these 9 elements are. It isn’t clear as there are 10 people in the trie before Sam got added.

2011-05-27
57TYPO

Bottom of the page: The structure of the tries after this selective copying -> should this be “of the trie”? It isn’t clear if the sentence refers to one or many.

2011-05-27
139TYPO

As you work though… -> As you work through…

2011-05-27
185TYPO

This sentence is easily misunderstood:
“To avoid that
we need to check if a sender is available before we call the replyUnsafe( )
method.”
Change it to:
“To avoid this from happening we need to check if a sender is available before we call the replyUnsafe( )
method.”

2011-07-10
CoverERROR

No cover image shows up on a Nook e-reader, just a blank page. This is for the EPUB version. The cover shows just fine in the PDF.

189SUGGEST

I suggest to not use new keyword to create case classes’ instances for messages in Scala examples

2011-07-10
64TYPO

In the first paragraph, there’s the following sentence:

“In general, we’ll don’t want to break down the problem too small as that may result in scheduling overhead.”

It sounds like what was intended was either “we don’t want to break (…)” or "we’ll not want to break (…). The way it is written doesn’t make much sense.

79ERROR

to ensure visibility stopEnergySource() has been made synchronized, but init() method (which initializes replenishTask field which is used by stopEnergySource()) is still un-synchronized.
Looks like a bug for me, or have I missed something?

147SUGGEST

It would be very useful to describe also what should be in the classpath to use Akka, Multiverse or Clojure STM from within Java.

147SUGGEST

It would be very useful to describe also what should be in the classpath to use Akka, Multiverse or Clojure STM from within Java.

69TYPO

In the withdraw method, the acquisition of monitor.lock() should be just outside the try block, not inside. I.e., move it up one line.

106ERROR

The following code does not work with akka.stm.Ref - I have tried all versions from 1.0 to 1.3.1.

private void init() {
replenishTimer.schedule(new Runnable() {
public void run() {
replenish();
if (keepRunning.get()) replenishTimer.schedule(
this, 1, TimeUnit.SECONDS);
}
}, 1, TimeUnit.SECONDS);
}
The Ref class does have a get() method inherited from the BasicRef class in the multiverse package. However, it does not return a Boolean - it has a return type E.

The only to methods in Ref that return a boolean are
getOrElse(boolean) and
getOrWait

I am not sure which one is used here.
Further, the book should mention which version of the software it is using and what are the dependencies for akka.

I would appreciate a response on this error.
Thanks
Amit
anand6998@gmail.com

11TYPO

“is froth with problems” should be “is fraught with problems”

146TYPO

At bottom, “still one of the most widely used language” (pluralize “languages”)

97TYPO

Hi, my Clojure isn’t great, so perhaps just my misinterpretation, but the let form (line 4 in both the deposit and withdraw functions) dereferences balance and assigns the value to a local called current-balance. But the function doesn’t use the variable current-balance thereafter. Loving this book and many others you’ve published. Cheers, Tim

1819ERROR

The demo Example do not run ,Today ,when I run the Example in page 18 ,The class :YahooFinance.java .The exmaple can not run ,Why ? I am a student from China ,Is the network Problem?

Categories: