03-27-2008, 08:05 AM
Hi ,I am experiencing a problem with QT Java 6.1 on Windows XP using Java1.4.2 (_2, _3, and _4) where a QT Component (as Component()) created from a Movie Controller placed in a window or frame will sometimes freeze when another window is placed in front of it or removed with set Visible(true/false). I cannot produce a test case or anything of the like because I cannot reliably reproduce it on command. The freeze
occurs on the set Visible () command. Looks like some DEADLOCK. Has anyone else experienced this?
Any suggestions? Ideas ? Thanks.
03-27-2008, 02:13 PM
To find solution for your problem lets see what dead lock is . A deadlock is a situation where threads are blocked because one or both are waiting for access to a resource that will not be freed. The application can never terminate because the threads are blocked indefinitely.
This behavior results from improper use of the synchronized keyword to manage thread interaction with specific objects. The synchronized keyword ensures that only one thread is permitted to execute a given block of code at a time. A thread must therefore have exclusive access to the class or variable before it can proceed. When it accesses the object, the thread locks the object, and the lock causes other threads that want to access that object to be blocked until the first thread releases the lock.
Since this is the case, by using the synchronized keyword you can easily be caught in a situation where two threads are waiting for each other to do something.
Of course, most deadlocks won't be quite so obvious simply from reading the source code, especially if you have a large multithreaded program. A good Source code analysis tool, like Coverity Prevent, finds deadlocks and points out their location in the source code so that you can fix them. Coverity has customers like Symbian, RIM (Blackberry), Juniper networks, Cisco, Texas instruments and is also used by the Department of Homeland security to scan lots of open source projects. You can get more info at http://www.Coverity.com.