+1  A: 

question #1: Just look at 'generation' as the group you (the thread) belongs to, whole groups are allowed in, so if the door opens the group # is increased, and everyone belonging to the group that was already waiting is allowed in, even if the door is seen as 'locked' again.

question #2: I guess that is an error - it probably should read 'every time the gate is opened ...'

Simon Groenewolt
#2: French edition (http://www.melafrit.com/outils/e-books/Programmation_concurrente_en_Java.pdf) uses "is closed" as well :)
Max
+1  A: 

For those, who are interested, seek for answer here.

In this listing the waiting thread T1 is interested if any open event happened during the wait (we do not care whether any close events happened), generation counter helps us to find out this fact.

Max