[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] Re: Thread,SWT,ASYN,SYN problem

Hi,

Both syncExec and asyncExec can be used to do something in the 'user
interface thread'. The main difference between them is explained in the
javadoc: the syncExec method causes your thread to wait for the specified
Runnable to finish but asyncExec is not: it returns immediately after it
'registers' the Runnable into the ui thread.

Example:
1. The specified Runnable (A) may or (most likely) may not be executed at
the time "A" is printed to the screen.
Display.asyncExec(A);
System.out.println("A");

2. The specified Runnable (A) is guaranteed to finish its work at the time
"A" is printed.
Display.syncExec(A);
System.out.println("A");

Note that - because the user interface thread is a single thread - it can
execute only one specified Runnable at a time. So your case is a normal
behaviour: first A is executed and then B either method you use.

HTH,
Regards,
Csaba

binjava wrote:
> hi everybody...
>
> who can tell me about difference of ASynExec and SynExec?
>
>
> i create two threads by display.synexec
>
> synexec(A)
> synexec(B)
>
> but B thread start still when A thread is finish.....
> why?
>
> A and B is ProgressBar....same...result..
>
> i try asynexec.....
> help...