dcsimg
Swing Threads can't update in sinc and hang with sleep() method
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Belsien_Thomas
Posted On:   Friday, February 14, 2003 02:21 AM

Hello, I have tried to write a simple program that counts up form zero and counts indefinately using a calendar object. I want to use it in a larger program however, I implemented 3 different timers using 3 different approaches and have found different problems with the counter on the standard thread because it lags behind the SwingTimer thread even though both started at the same time. There is a lag about 2-3 seconds per minute and another problem is with a thread that I try to make sleep on the EventDispatching Thread as is needed for a timer but the whole program will hang. The SwingUtility won't work and if you start it in the code all GUI work hangs on the EventDispatching Thread. If anyone can ex   More>>

Hello,

I have tried to write a simple program that counts up form zero and counts indefinately using a calendar object. I want to use it in a larger program however, I implemented 3 different timers using 3 different approaches and have found different problems with the counter on the standard thread because it lags behind the SwingTimer thread even though both started at the same time. There is a lag about 2-3 seconds per minute and another problem is with a thread that I try to make sleep on the EventDispatching Thread as is needed for a timer but the whole program will hang.
The SwingUtility won't work and if you start it in the code all GUI work
hangs on the EventDispatching Thread.


If anyone can explain what is going on to me with the example or can show me a working example of a timer running on a swing program that is better I would appreciate it. My email is belsien@compeducation.com. Again the problem is with the Thread.sleep() command on the EventDispatching Thread with the SwingUtilities invokeLater() method.


The 3 Threads are:


1) Generic Thread

2) SwingTimer firing on actionPerformed() method

3) Generic Thread (same as #1) executed with SwingUtilities.invokeLater()




I put the code in a Swing Applet and posted the Source code below it at www.compeducation.com/DifferentSwingCountersApplet.html Thanks in advance for any help.

   <<Less
About | Sitemap | Contact