| [news.eclipse.platform.swt] Re: aSyncExec behavior |
Spencer Stejskal wrote:
does Display.aSyncExec(Runnable) only run its runnable when the display thread returns to the event loop?
more specifically if the spawned thread below in the nonBlockingMethod gets to LINE Y before the display thread gets to LINE X is the potential there for the
display thread to run the runnable in the asyncExec call before the display thead finishes the someMethod invocation or will it wait until its back into the display loop?
private class SomeClass
{
private List list = new ArrayList();
public void someMethod()
{
long pid = nonBlockingMethod(display); {called from the display thread, dont worry about where the display is retrieved from}
//do some more work, maybe long maybe short
LINE X list.add(pid);
}
private long nonBlockingMethod(final Display display)
{
long pid = generatePID();
Thread t = new Thread(new Runnable(){
public void run()
{
//do some work, maybe long maybe short
LINE Y display.asyncExec(new Runnable(){
public void run()
{
if(list.contains(pid))
{
//do one thing
}
else
{
//do another thing
}
}
});
}
});
t.start();
return pid;
}
}