By my counts the mutex stuff will allow many mouse events to go past the rendering thread. OK for this example, but if you want to do something like mouse panning then you cant afford to lose a single mouse event. It could be the mouse release event.Here is my bodged solution

this way all incoming mouse event are stopped at the top and are only let through one at a time. I have a supsicion the order may not be preserved though. So those who need it might need a list or something. I have also in my example thrown out the dragged and moved if they have to be delayed. Some will still get through, its jsut so I don't get a massive pilup of those inessential events, enough will get through to my underlying behavour

Tom

Runesketch: an Online CCG built on Google App Engine where players draw their cards and trade. Fight, draw or trade yourself to success.

If you don't want to lose events, you can save them in a list instead of just setting a boolean flag. For the tutorial this isn't a problem. The synchronizing makes sure the rendering thread isn't interrupted while executing the picking code.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org