• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Increase the priority of EventDispatcherThread

 
RAVI Kollepara
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am doing a project with JDK1.4 and RH Linux. with the embedded processors. Here i am having the problem with the EventDispatcherThread. Itz responding very late. so , i want to incrase its priority. Is there any way to increase itz priority.
Thanx
Ravi Kollepara
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Much simpler to assign lower priority to your worker Threads.
Perhaps your design tries to do too much computation using the event Thread - this is a common mistake.
Bill
 
RAVI Kollepara
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thatz not the way to increase the priority. Do u know what is the priority of Event Dispatcher thread in JVM? We have a timer threads in our project which are always should be in HIGH priority. Now tell me the solution.
Priority of the Event Dispatchter thread is 7
Thanx,
Ravi
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect your EventDispatcher Thread is very busy doing work that should be assigned to worker Threads. If that is true, it doesn't matter how high the priority is, it will still be slow responding.
Bill
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I strongly agree with Bill here. But if you really want to change the event dispacher priority, here's how:

I suspect this won't actually improve your execution at all, for the reasons Bill described. If your event dispatcher is really busy, it's probably running almost all the time anyway; increasing its priority won't help. What you typically need here is to figure out which tasks are really time-consuming, and delegate those to other threads, not the event dispatcher thread. That way the dispatcher will be able to respond to new events, even though the other threads are still processing.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a timer threads in our project which are always should be in HIGH priority.
Are you trying to change the priority of the timer threads, or of the event dispatcher thread? You're not trying to run a timer or some sort in the event dispatcher, are you? That would certainly explain why it's slow to respond.
 
RAVI Kollepara
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!