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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:22:34+00:00 2026-05-27T10:22:34+00:00

I have an application that is redirecting my System.out text to a Jtextarea. This

  • 0

I have an application that is redirecting my System.out text to a Jtextarea. This works fine but when I call one of the methods in my application is creates multiple threads and uses a latch counter to wait for them to finish. That method then calls latch.await() so that it does not finish running its code until the other threads are finished. The problem is that once the latch.await() code is called my JtextArea stops posting text until all the threads have finished. Any ideas around this? Eclipse console is able to keep posting while the latch.await() is running so it has to be possible.

Example:
From the GUI:

btnStart.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.out.println("You pressed Start");
MyGoogleSearch startParsing = new MyGoogleSearch();
try {
startParsing.startParser(othoSelection); ...

MyGoogleSearch:

Enumeration e = hm.elements();



    //Read in src/Ontology/Ontology.txt
    //Put each line into the searchQuery ArrayQueue
        while ((strLine = br.readLine()) != null)   
        {  
            searchQuery.put(strLine);
        }
        System.out.println("Finsihed loading");

        //Create 32 threads (More threads allows you to pull data from Bing faster.  Any more than 32 and Bing errors out (you start to pull data
        //too fast)
            for(int i = 0; i < 32; i++)
            {
                System.out.println("Starting thread: " + i);
                new NewThread();
            }

    //Wait for all of the threads to finish
    latch.await();
    e = hm.keys();

    //Write the URL's from the hashmap to a file
        while (e.hasMoreElements())
        {
            out.write(e.nextElement() + "\n");
        }

        //close input/output stream
        in.close();
        out.close();
        System.out.println("Done");

and the Thread does some stuff then

MyGoogleSearch.latch.countDown();
  • 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-27T10:22:35+00:00Added an answer on May 27, 2026 at 10:22 am

    This works fine but when I call one of the methods in my application is creates multiple threads and uses a latch counter to wait for them to finish.

    You could get around that by calling the method in a separate thread. However, I suspect the method is waiting for all the threads to complete because it wants to aggregate some results and then return the aggregated result (or something similar). If that’s the case, then there are several ways to deal with it, but probably the one that will make the most sense for a graphical application is to have the thread invoke a callback with any results which were obtained from the method.

    If you post some sample code, then we can provide you with more specific answers and examples of how to do it.

    Update:

    I’m having a hard time reading your code, but I presume that ‘startParser’ is the call that’s blocking. Additionally, it doesn’t appear that the UI needs to wait for the results so I would recommend you do the simplest thing possible:

    MyGoogleSearch startParsing = new MyGoogleSearch();
    
    Thread t = new Thread(new Runnable(){
        public void run(){
            startParsing.startParser(othoSelection);
        }
    }
    
    // don't wait for this thread to finish
    t.start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that goes like this F5 load balancer - IHS(a&b) -
I have an application that has 2 beans with the same name, but which
I have a facebook iframe application that is having trouble redirecting, I keep getting
I have an old web application that's being migrated to a different system, and
I have an ASP.Net MVC 3 application that uses a jQuery .ajax call to
I have application that makes different queries with different results so the caching in
I have application that is connecting to the DB and if I enter incorrect
I have application that is up more than 3 days. I can see in
I have application that brings response via Ajax and creates 5-20 new jQuery click
I am building a Rails application that contains Developer s who have Application s.

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.