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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:40:57+00:00 2026-05-29T10:40:57+00:00

I’m in the process of designing a Java GUI driven application that runs a

  • 0

I’m in the process of designing a Java GUI driven application that runs a number of separate tasks, each within its own SwingWorker extended class. This is the normal design I use in order to run tasks on their own threads and still keep the EDT free to update the GUI. Each SwingWorker is started on its own thread using an Executors.newCachedThreadPool.

However, within one particular class, there is a task that requires quite a long time to process. The task contains a for loop that performs some calculations up to six times.

I’ve had the thought of implementing each of the six calculations within their own thread to speed up processing time, but I’m not sure of the best way of implementing this.

Is it possible to both extend SwingWorker and implement Runnable, and then use a void Run() method within the for loop, starting a new Thread each time, or using a cachedThreadPool.

Or am I better off just using standard Thread() implementation?

Any advice or suggestions would be appreciated.

Thanks in advance

Josh

  • 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-29T10:40:58+00:00Added an answer on May 29, 2026 at 10:40 am

    user988052 is right of course – if you don’t have a multi core CPU, doing the computation in six different threads will actually slow down your application because of the overhead that comes with the creation and administration of threads.

    If you want to do this calculations in six separate threads nevertheless, you could use a SwingWorker as the managing thread and spawn off 5-6 new threads within it. Using ExecutorService would then be the way to go, since it uses a pool of threads and thus minimizes the overhead that comes with the creation and disposal of a thread.

    Edit: to answer your comment:

    I think the best way would be the implement your calculation in a Runnable (so that each of the six calculations can run separately), then simply use an ExecutorService, instantiate your Runnablesix times and use ExecutorService.submit(Runnable task). You can do all of this within the SwingWorker.doInBackground() method.

    You should never call the run() method yourself – let that be done by a Thread/ExecutorService.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.