Locks were introduced to provide finer control on locking and unlocking on JDK 1.5, but it is still one of the most underused feature. It's a powerful alternative of synchronized keyword but if not used carefully can create really subtle bugs, because responsibility of acquiring and releasing locks lies on Java Programmer. In this article, we will learn how to use locks in concurrent Java program with simple example.
The events generated by the mouse come under low-level events. We have seen previously how to handle the events of a mouse when the mouse is stable with MouseListener. Let us handle the events when the mouse is in motion.