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 8230011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:59:27+00:00 2026-06-07T16:59:27+00:00

There is actually more than 1 question. Given Model View and Controller. (Mine are

  • 0

There is actually more than 1 question.

Given Model View and Controller. (Mine are coupled a lot – View knows its Controller, and Controller knows View.)

Does new threads in Controller can be fired in basic manner – with the new Runnable(){ (...) run(){}} or it is required to do in some “swing way”, to make it properly? Maybe with Timer or invokeLater()?

Second thing is – assuming that new thread has started – when it operates directly on view, setting some JTextFields (and so on) – do methods such as setThatTextFieldWithNewValue(msg) need to be synchronized as a result of being called from need thread? If so – is there any better approach that gives less coupling and less spend time thinking about needed synchronization?

  • 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-06-07T16:59:29+00:00Added an answer on June 7, 2026 at 4:59 pm

    Anything in swing has to run on the EventQueue. If you have a method called from swing it will already be running there (as in an Action listener). If you don’t know if you’re on the event queue, EventQueue.isDispatchThread() will tell you. When you know you’re not, reference a swing class or method using EventQueue.invokeLater() or invokeAndWait if you need to see results. (This must be done from the main method.)

    Be very careful about this; you have to check your code. If not, my experience is that the swing UI will be just a little bit flakey, with the occasional unreproducable oddity. There’s no easy way around eyeballing each line of code.

    Actually, there is. Do everything on the EventQueue, then you won’t have to worry. You’re probably not doing a whole lot of work outside swing anyway. If you are, it’s probably worth the loss of speed to avoid multithreading problems. If your non-swing work is extensive but simple, use the SwingWorker class. It gives you an extra thread under highly controlled conditions and should save you a lot of grief.

    Your classes (View and Controller) are independent of threads, and should work just fine all running in one thread. Don’t confuse classes and threads. (I’ll admit, I’d be tempted to have the Controller firing off threads in all directions, but you have to be prepared to be very careful and know everything there is to know about multithreading.)

    If you do multithread, the EventQueue can be a bit handy because you don’t have to protect fields referenced only there–it’s an island of single threading in a dangerous sea. On the other hand, don’t do any synchronization there; you’ll block your UI. You can launch threads from there and you may have to just to avoid blocking. (Once you start multithreading, it’s hard to stop.)

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

Sidebar

Related Questions

Be forewarned: This question seems way more obvious than it actually is. I'd like
Actually this is more than one question, but seems kind related. I appreciate any
I have a general question about interpreters of functional languages: Are there actually any
There are actually 2 question i want to cover in this topic. 1) Is
Is there a straight forward way to view the SQL command text actually executed
I know this is more heavy question, but I think its interesting too. It
This is a question more about best practices/design patterns than regexps. In short I
I am curious if there is actually a mark-up language to describe the meanings
Hi I'm getting strange feedback from the feedback sandbox server. Actually there should be
There doesn't seem to be a clear documentation for what permissions are actually required

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.