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

  • Home
  • SEARCH
  • 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 8453679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:49:24+00:00 2026-06-10T11:49:24+00:00

I read that you shouldn’t .show() frames on the main thread to avoid deadlock,

  • 0

I read that you shouldn’t .show() frames on the main thread to avoid deadlock, is this a real problem. Should this always be avoided? Also once you display any sort of dialog box, such as a ProgressMonitorInputStream, even if it closes and is done, must you still call System.exit() to kill the app? What about a JDialog?

  • 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-10T11:49:25+00:00Added an answer on June 10, 2026 at 11:49 am

    I read that you shouldn’t .show() frames on the main thread to avoid deadlock

    It’d stop reading that book/post/webpage.

    To address your first point:

    I think you may be missing some points.

    All UI code MUST be executed on the Event Dispatching Thread (EDT), this includes UI components that aren’t even on the screen yet.

    You should NOT perform time consuming tasks one the EDT as this will prevent the screen from been updated and make your application non-responsive, which users really, really hate.

    Time consuming tasks should be performed in there own Thread (this is actually an entirely different topic), using some thing like SwingWorker or SwingUtilities.invokeLater/andWait to resync/update the UI.

    public class BackgroundTask implements Runnable { // extends Thread {
    
        public void run() {
            for (int i = 0; i < noQueries; i++) {
                runDatabaseQuery(i);
                updateProgress(i);
            }
        }
    
        private void updateProgress(final int queryNo) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    statusLabel.setText("Query: " + queryNo);
                }
            });
        }
    }
    

    To address your second point:

    Yes and no. The JFrame class provides a defaultCloseOperation which you can use to terminate the main application.

    However, if all you ever display is JDialog or other type of window, yes, you will need to call System.exit in order to terminate the JVM.

    Where it’s supported, you can use a WindowListener.windowClosed event to monitor when you window is closed and take appropriate action.

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

Sidebar

Related Questions

I just learned about ThreadLocal this morning. I read that it should always be
I've read some posts stating that using this method is not good, shouldn't be
I always read that I should use model = Model(a=5, b=6) model.save() But I
You always read that for-in loops should check o.hasOwnProperty(k) to skip over Object.prototype. Well,
I have read that you should keep the number of connections in your database
I've read that good programming practice claims that one should use a function if
Im writing a program that should read input via stdin, so I have the
I just read that C99 has double_t which should be at least as wide
Q1 I’ve read that when setting the timeout of an authentication cookie, we should
I'd read that when renaming files in Git , you should commit any changes,

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.