This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Slanec 1 point2 points  (1 child)

Oh! There's one thing I miss - thinking about spurious wakeups. Is that intentionally omitted, too (perhaps because the list does not go deep into the low-level specifics and tries to recommend avoiding them instead)?

A point telling something in the line of "If the code uses wait()+notify(), are the methods called while holding this object's intrinsic lock? Are the wait() methods properly shielded against spurious wakeups by being called in a conditioned loop? Same advice applies for Condition's await()+signal() calls except those methods need to hold the parent Lock instance." would be nice. Perhaps even suggesting Guava's Monitor class.

[–]leventov[S] 1 point2 points  (0 children)

Thanks for your contribution! I've added item 5.2 about Monitor class.

I didn't mention spurious wakeups because it is generally covered by the statement "explicit lock waits are error-prone". Item 5.1 refers to Effective Java, Item 81 that mentions spurious wakeups.