Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Simple Display.asynchExec() problem
Simple Display.asynchExec() problem [message #454476] Thu, 21 April 2005 21:45 Go to next message
Duncan Krebs is currently offline Duncan KrebsFriend
Messages: 79
Registered: July 2009
Member
I can't figure out what in the world I'm missing here. All I'm trying to
do is to run a simple thread using Display.asynchExec(). The problem is
that the GUI locks up until the seperate thread is finished executing (as
if it were executing using display.synchExec()).

For example the code below will lock up the GUI until its loop is
finished. I give up, does anyone see what is wrong?
Display.getCurrent().asyncExec (new Runnable () {
public void run () {
for(int i = 0; i < 10000; i++)
System.out.println("hello from asynchExec thread");

}
});
Re: Simple Display.asynchExec() problem [message #454479 is a reply to message #454476] Thu, 21 April 2005 23:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

asyncexec does not start a new thread. What it does is run the runnable
in the UI thread. So if your runnable does alot of things, it will lock
up the ui thread.

asyncexec means queue it off and the UI thread will run it when it gets
a chance. syncexec means run this runnable in the ui thread now, and
don't return until it has completed.


--
Thanks,
Rich Kulp
Re: Simple Display.asynchExec() problem [message #454552 is a reply to message #454479] Sun, 24 April 2005 03:52 Go to previous message
Duncan Krebs is currently offline Duncan KrebsFriend
Messages: 79
Registered: July 2009
Member
Rich,
Thanks for the pointers, it helped me figure out the concept, SWT is
forcing me to learn more about threads. With that I completed the task of
redirecting the system.out to a text widget in my SWT app. Yahoo!

> asyncexec does not start a new thread. What it does is run the runnable
> in the UI thread. So if your runnable does alot of things, it will lock
> up the ui thread.

> asyncexec means queue it off and the UI thread will run it when it gets
> a chance. syncexec means run this runnable in the ui thread now, and
> don't return until it has completed.
Previous Topic:eclipse doesn't load button images
Next Topic:PNG support in SWT Toolbar
Goto Forum:
  


Current Time: Fri Apr 26 04:54:32 GMT 2024

Powered by FUDForum. Page generated in 0.02896 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top