Please take a look at the following code snippet. A threadpoolExecutor object is created with the following two lines of code.
private final ExecutorService myThreadPool;
this.myThreadPool = Executors.newCachedThreadPool();
Now there are a bunch of asynchronous threads that have reference to the myThreadPool object. They might be invoking
myThreadPool.submit(Runnable Task) asynchronously
Q 1.) Is myThreadPool thread safe ?.
Q 2.) If I want to synchronize what is the best way to synchronize this with minimal impact to application performace
Q 3.) If I make the submit task return a Future object
Future <x> = myThreadPool.submit(Runnable Task);
Will the performance be slow ?
Thanks Much
private final ExecutorService myThreadPool;
this.myThreadPool = Executors.newCachedThreadPool();
Now there are a bunch of asynchronous threads that have reference to the myThreadPool object. They might be invoking
myThreadPool.submit(Runnable Task) asynchronously
Q 1.) Is myThreadPool thread safe ?.
Q 2.) If I want to synchronize what is the best way to synchronize this with minimal impact to application performace
Q 3.) If I make the submit task return a Future object
Future <x> = myThreadPool.submit(Runnable Task);
Will the performance be slow ?
Thanks Much