Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » best way to distinguish main ui thread and background threads(RAP 2.3.2)
best way to distinguish main ui thread and background threads [message #1732881] Sat, 21 May 2016 19:50 Go to next message
Eclipse UserFriend
Hello

I have a method that should be accessed only by background threads. I want to throw AssertionError if the method is accessed by the main UI thread.

I tried
if (Display.findDisplay(Thread.currentThread())!=null)
but this line throws illegal state exception itself.

If I print thread name directly by
Thread.currentThread().getName()
it prints: UIThread [...]

Is there any way to get the main thread name "UIThread [...]" from RAP api? For now I store the main thread name to a static variable when the application starts up. That's not handy. What is the best way to check whether the executing thread is main thread or background thread in RAP? Thanks
Re: best way to distinguish main ui thread and background threads [message #1732888 is a reply to message #1732881] Sun, 22 May 2016 02:44 Go to previous message
Eclipse UserFriend
Tass,

Try org.eclipse.swt.widgets.Display.getCurrent().

On 22.05.2016 01:50, Tass Burrfoot wrote:
> Hello
>
> I have a method that should be accessed only by background threads. I
> want to throw AssertionError if the method is accessed by the main UI
> thread.
>
> I tried
> if (Display.findDisplay(Thread.currentThread())!=null)
> but this line throws illegal state exception itself.
>
> If I print thread name directly by
> Thread.currentThread().getName()
> it prints: UIThread [...]
>
> Is there any way to get the main thread name "UIThread [...]" from RAP
> api? For now I store the main thread name to a static variable when
> the application starts up. That's not handy. What is the best way to
> check whether the executing thread is main thread or background thread
> in RAP? Thanks
Previous Topic:Questions regarding context menus
Next Topic: Correct usage of ProgressMonitorDialog with modal dialogs
Goto Forum:
  


Current Time: Tue Jul 08 19:00:32 EDT 2025

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

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

Back to the top