I'm getting hurt, the simple use of the swing worker I've added some simple code to doInBackground (), but it does not execute Done, I did not get an exception. When I use a debugger, it should work. )) Maybe somebody did something like this, or tell me how to cache this mistake, or ... Sorry, the code is complex. Tell me if you need some more or comment if I "installer" I remove setFPS (fpsCalculatorGhost.getFPS ()); " - String, everything will be fine.
java.awt.EventQueue.invokeLater (new runnab () {public zero run (new key window). Set isob (true);}}); Public manwindows () {initComponents (); } Private Zero initComponents () {InterfaceUpdateWorker interfaceUpdate = new InterfaceUpdateWorker (New Interface InfoInstallerImpl ()); InterfaceUpdate.setCamera (gleventListenerImpl.getCameraGhost ()); InterfaceUpdate.setfPSCalculatorGhost (gleventListenerImpl.getFPSCalculatorGhost ()); InterfaceUpdate.execute (); } @ Override Protected Voice Doinebackground () throws exception exception {while {true} {installer.setFPS (fpsCalculatorGhost.getFPS ()); Installer.setCameraXPosition (cameraGhost.getCameraXPosition ()); Installer.setCameraYPosition (cameraGhost.getCameraYPosition ()); Installer.setCameraZPosition (cameraGhost.getCameraZPosition ()); Thread.Sleep (200); }} Public Final Category FPSCalculatorGhost {Private FPSCalculatorGhost () {} Public Float getFPS () {back fpsTask.getAvrfps (); }} Public float getAvrfps () {synchronize (this) {return avrfps; }} Everything FPS revolves around task-object. It is used by the interface update-thread (or application worker thread) and it is used by other threads, where it is started. Result: 1) FPS Task object is started in a thread 2).
When I fpsTask from the FPSCalculatorGhost Finals, it starts working.
Therefore, the problem is installer.setFPS (fpsCalculatorGhost.getFPS ()); What does the line do? It calls the getAvrFPS method, and it blocks: synchronize (this) {return ARFF; } This synchronized block can be entered only when another thread is synchronized in some synchronized blocks or similar objects at the same time. Do not be. There is no such block / method in the code snippet you posted, so you have to find it yourself. Most importantly, make sure that the other thread holding the lock is not waiting for this worker to get some results.
When you run in deadlock, run jstack with process-id of your Java process to get stack traces of all threads - they include locks and wait ( jps gives you all Java process IDs.)
Comments
Post a Comment