Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Display.syncExec() does not work
Display.syncExec() does not work [message #138972] Thu, 02 July 2009 11:25 Go to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
I am calling getDisplay().syncExec() in a non-ui thread.
getDisplay() returns a valid display (not null).
Unfortunately, the application is deadlocked and I have to kill it.

When using getDisplay().asyncExec() the deadlock will not occur.

What is wrong?
Re: Display.syncExec() does not work [message #139190 is a reply to message #138972] Fri, 03 July 2009 10:32 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
with a simple scenario I cannot reproduce what you describe. It may
have to do with the code you execute in the runnable.
Please file a bug if you can provide a standalone snippet to reproduce.


Erdal Karaca wrote:
> I am calling getDisplay().syncExec() in a non-ui thread.
> getDisplay() returns a valid display (not null).
> Unfortunately, the application is deadlocked and I have to kill it.
>
> When using getDisplay().asyncExec() the deadlock will not occur.
>
> What is wrong?
>
Re: Display.syncExec() does not work [message #140168 is a reply to message #139190] Tue, 14 July 2009 10:51 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
This is my code:

----------8<-----------------
// the display cached somehow when UI created
Display d = getUIThread();

// Thread.currentThread() is a worker thread
if ( d.getThread() != Thread.currentThread() ) {
d.asyncExec( run );
} else {
d.syncExec( run );
}
----------8<-----------------

I have to "convert" Display.syncExec() calls to Display.asyncExec() calls
when the runnable is executed in a worker thread
[d.getThread() != Thread.currentThread()]

I must execute the runnable in the ui thread from the worker thread, but
the ui thread is waiting for the worker thread to complete...

Rüdiger Herrmann wrote:

> with a simple scenario I cannot reproduce what you describe. It may
> have to do with the code you execute in the runnable.
> Please file a bug if you can provide a standalone snippet to reproduce.


> Erdal Karaca wrote:
>> I am calling getDisplay().syncExec() in a non-ui thread.
>> getDisplay() returns a valid display (not null).
>> Unfortunately, the application is deadlocked and I have to kill it.
>>
>> When using getDisplay().asyncExec() the deadlock will not occur.
>>
>> What is wrong?
>>
Re: Display.syncExec() does not work [message #140180 is a reply to message #140168] Tue, 14 July 2009 13:13 Go to previous messageGo to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
Hi Erdal,

could'n you replace
d.syncExec (run)
with
run.run();

If you are already in the UIThread there's no need to use syncExec, I think.

Regards,
Stefan.


Erdal Karaca schrieb:
> This is my code:
>
> ----------8<-----------------
> // the display cached somehow when UI created
> Display d = getUIThread();
>
> // Thread.currentThread() is a worker thread
> if ( d.getThread() != Thread.currentThread() ) {
> d.asyncExec( run );
> } else {
> d.syncExec( run );
> }
> ----------8<-----------------
>
Re: Display.syncExec() does not work [message #140184 is a reply to message #140180] Tue, 14 July 2009 13:32 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Yes, you are right, but I am not in the UIThread...

> could'n you replace
> d.syncExec (run)
> with
> run.run();

> If you are already in the UIThread there's no need to use syncExec, I think.
Re: Display.syncExec() does not work [message #140187 is a reply to message #140184] Tue, 14 July 2009 13:46 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
The problem: ui thread waits for worker thread to complete... worker
thread needs to execute code in ui thread...
If worker thread calls Display.asyncExec() there is no deadlock, but
calling Display.syncExec() will cause the deadlock.

How would you resolve this?
Re: Display.syncExec() does not work [message #140196 is a reply to message #140187] Tue, 14 July 2009 19:38 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Erdal,

Display#syncExec works as expected for me. Your snippet does not explain
how a deadlock occurs. Can you provide a simple snippet that reproduces
the deadlock?

Regards, Ralf

Erdal Karaca wrote:
> The problem: ui thread waits for worker thread to complete... worker
> thread needs to execute code in ui thread...
> If worker thread calls Display.asyncExec() there is no deadlock, but
> calling Display.syncExec() will cause the deadlock.
>
> How would you resolve this?
Re: Display.syncExec() does not work [message #140419 is a reply to message #140196] Wed, 15 July 2009 06:55 Go to previous message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
See this bug report:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=283490
Previous Topic:More convenient ConfigIniCreator.java and a warBuilder.xml for deploying RAP apps
Next Topic:error in RAP 1.2: THEME_VALUE is not defined
Goto Forum:
  


Current Time: Wed Apr 24 21:15:24 GMT 2024

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

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

Back to the top