even if we use invokeandwait the inner thread reference will be kept in eventdispatcher thread.
CurrentThread in the sense there is no necessity that we will get the handler of EventDispatcher thread.
Anyway let me ask one question that i have faced in my project.
/**
*Class to blink the sub title lable
*/
private class BlinkingThread
implements Runnable
{
private boolean stopTheThread = false;
private Thread currentThread = null;
public BlinkingThread()
{
currentThread = new Thread(this);
currentThread.setPriority(Thread.MAX_PRIORITY);
}
public void run()
{
try
{
while(!stopTheThread)
{
currentThread.sleep(1000);
lblSubInfo.setVisible(false);
currentThread.sleep(1000);
lblSubInfo.setVisible(true);
}
}
catch(Exception ex)
{
System.out.println("Error blinking the sub title:"+ex.getMessage());
}
}
public void startTheThread()
{
currentThread.start();
}
public void stopTheThread()
{
stopTheThread =true;
}
}
This is the code segment the lable has to blink at the rate 1Hz. The thread is running properly. But the updation of lable is not proper. sometimes it will be fast and sometimes it will be slow. What could be the reason. What i am suspecting is the repaint events is getting queuedup. Any suggestions. There are one more High priority thread is running on the machine that is timer thread.
Any ideas?