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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:36:04+00:00 2026-06-15T10:36:04+00:00

I am writing a Java Fractal Explorer, and the fractal calculation is done multi-threaded.

  • 0

I am writing a Java Fractal Explorer, and the fractal calculation is done multi-threaded. Previously, I just created a bunch of threads (as many as the system has processor cores) and held them in an array, but this results in a several problems and is not very elegant, and now I want to switch to Executors.

The functionality I need is:

  • The user can, at any time, select a new area of the fractal image to zoom into, so it should be possible to cancel the calculation at any time, and immediately reinsert new tasks
  • For better performance, threads should be reused (and survive a cancellation)

My problem is that the Java ExecutorService (I use an Executors.newFixedThreadPool()) throws exceptions when I submit new tasks after a call to shutdownNow() (cancelling). I could of course just create a new ExecutorService, but then all the threads would have to be created again, which is, as far as I understand, quite expensive (which is the whole point of using thread pools).

So basically what I need is a ExecutorService implementation using a thread pool that can be cancelled without shutting it down, so it can be reused.

Is there already such a thing or do I have to write it myself? (Can’t be too hard, right? 😉 )

My current code can be found at https://github.com/lucaswerkmeister/JFractalizer.

Thanks in advance,

Lucas

PS: When using executors, I would split the image in more parts than there are threads, so if one part finishes much faster, the thread is not idle, but can instead continue on another part of the image. It would be cool if nevertheless all the parts would be calculated in parallel and not some starting later than others, but that’s just a bonus.

  • 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-15T10:36:05+00:00Added an answer on June 15, 2026 at 10:36 am

    You should use ExecutorService.html#shutdownNow() when you’re done with the ExecutorService and you don’t intend to submit new tasks to it.

    If you want to keep using the same ExecutorService, you should cancel the individual tasks.

    Method ExecutorService.html#submit returns a Future that can be used to cancel execution and/or wait for completion.

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

Sidebar

Related Questions

I usually C++ applications. The only web-application development I've done is writing Java Applets.
Having been writing Java code for many years, I was amazed when I saw
Just started writing java / android and I am trying to use android.widget.VideoView. I
i am writing java code to create a tabs.i have done that.but now i
I'm writing Java in eclipse and I'm just wondering if there's a shortcut or
I am reading and writing Java Properties files in XML format. Many of the
For various reasons calling System.exit is frowned upon when writing Java Applications , so
I've just started writing Java and I'm trying to make a simulation of a
I've been writing Java for the last couple of years , and now I've
Sometimes while writing Java in Eclipse, I write code that generates warnings. A common

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.