I have a class containing an ExecutorService that can be shared between threads:
class MyExecutor {
ExecutorService e = Executors.newSingleThreadExecutor();
....
....
public void add(Runnable r) {
e.executre(r);
}
}
Is it necessary to synchronize the ExecutorService object in the add
method since the add
method can be called from differens threads or is the ExecutorService thread safe?