multithreading - Java: guide-line for when to use thread-pooling? -


this high-volume production system, however, particular code path seldom used. import feature can potential result in lot data coming in, it's used, few times month, perhaps.

having (polite) debate colleague. issue whether simple thread created old fashioned way:

runnable thread = new runnable() {   public void run() {     //... import work ...   }; } new thread(thread).start(); 

is sufficient, or if requires using thread pool.

this happening in service-layer class called servlet (providing restful interface). purpose being allow response return , free ui while import happens.

as follow on - in situation, using thread pool going add more unnecessary (coding , resource use) overhead?


after ejp's comment - there guideline when becomes 'worth having discussion' using pooling instead of straight thread creation?

a threadpool useful if planning on starting lot of these threads, , avoid thread creation overhead re-using them instead of kill + re-creating them subsequent work.

since code path used rarely, not need threadpool.

however, sounds doing heavy work in same process serves rest api? may want consider passing work worker runs in separate process.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -