• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Multiple Executor Service

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to optimize some codes and I noticed that it is trying to create multiple executor services with 10 threads each.
When the loads increased, the runtime became exponential.

Is it better to just create 1 executor service running?
 
Ranch Hand
Posts: 174
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Executor service itself does not add much overhead to execution to threads. It just uses some synchronization mechanisms like semaphores to communicate to the threads. So, if you are facing some issues with the load, the problem lies somewhere else.
 
Bartender
Posts: 653
14
TypeScript Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure how would it affect performance but that seems like it is a code smell either way.
 
Saloon Keeper
Posts: 26547
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As long as the number of spawned threads is less than the machine's total CPU core count, overhead should be fairly low, although if they fight for I/O resources or something like that, it can be counter-productive.

Once you have more threads than cores, CPU-intensive code will suffer. I/O-intensive code is generally OK - as long as you don't stack them all up waiting on specific I/O resources.
reply
    Bookmark Topic Watch Topic
  • New Topic