• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Converting threadgroup to executorservice

 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following code seems to run correctly. The goal is to start four threads on two threadgroups, and then cancel the threads after some calculations are finished, but before the calculation is completed.

I would like to change the code to limit the number of threads submitted at one time.

One approach to limiting the number of thread submitted at one time is to use executor service. But, when I try to convert to executor service, then the code doesn't produce any results.

How should the code be modified to use executor service?
Is there another way to limit the number of threads running at one time? The worker threads are computationally intensive, and would typically run for several minutes.




 
John Vorwald
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Somedays I think I know what I'm doing, other days ...

I played with some example codes, and came up with the following implementation of an executor service that has a cancel flag, which is what the previous code was on.

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic