Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6731535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:32:26+00:00 2026-05-26T10:32:26+00:00

I have an SWT application. I was frustrated at SWT for not making it

  • 0

I have an SWT application. I was frustrated at SWT for not making it easy to do what I wanted to do. So I used Swing. Swing made my life easy. Yay. Except now, the two have to talk. The issue is, they are running on different threads, and whenever I try to run an SWT GUI method from Swing, I get:

Exception in thread "AWT-EventQueue-0" org.eclipse.swt.SWTException: Invalid thread access

Oh joy. So, how do I fix this? If this was Objective-C, I could use:

- (void)performSelector:(SEL)aSelector onThread:(NSThread *)thr withObject:(id)arg waitUntilDone:(BOOL)wait

But it’s not, so I can’t. Is there no way to run method A on thread B? When that thread is existing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:32:27+00:00Added an answer on May 26, 2026 at 10:32 am

    I haven’t worked much with SWT but it seems that SWT will striclty prohibit accessing an SWT object in the non UI thread. You can queue up a request to talk to an object on the SWT.

    This link explains this better

    The example suggests you to use syncExec

    display.syncExec(
      new Runnable() {
        public void run(){
          label.setText(text);
        }
      });
    

    This I can assume will queue up the Runnable on the main SWT UI thread and thus the access would be legal.

    Note: I read over the link again, syncExec will end up freezing your Swing EDT. If you invoke syncExec, it will throw the Runnable on the SWT queue and wait for it to be completed. You can look at asyncEvent to throw the runnable on the queue and continue on working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SWT/JFace application that uses the Realm (not sure of the concept)
I have a tiny (rikiki) problem in SWT ... I am making a small
I have a Java Application using SWT as the toolkit, and I'm getting tired
I'm designing a Java application using SWT. I have some tables which will display
I have inherited development of a Java/SWT application running on Windows only. One of
Java Desktop application: SWT vs. Swing requires native libraries for each supported system Does
I have an SWT application which is quite complex at the moment. And I
I have written an SWT Java application and would like to configure it to
I am trying to communicate with Excel from a Java/SWT application. I have been
Right now i've written a simple SWT application using eclipse, and I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.