views:

95

answers:

3

The javadoc for

Executors.newSingleThreadScheduledExecutor 

says "... the returned executor is guaranteed not to be reconfigurable to use additional threads".

What does the above sentence mean? Does it mean the returned instance may not have nested threads?

+3  A: 

It means that you cannot add additional threads to this executor after it has been created. It is guaranteed to have only one thread.

This is useful when want to ensure that only a single background task is active at any given time in your application. Mostly useful when you will be providing a reference to this executor to potentially untrusted code (code written by someone other than you).

Gerco Dries
I'm sorry, I still do not understand. Does this mean, for instance, an active thread may not instantiate and activate another thread ?
Everyone
No, it means exactly what it says. The *Executor* will *never* use more than one thread. What this thread does is of no concern to the `Executor`.
Bombe
As Bombe is saying. The tasks the Executor runs are capable of doing whatever they like. They can create more threads if they want to. The Executor simply guarantees that it will not use more than one thread for running tasks.
Gerco Dries
+1  A: 

It means, that if you share the Executor, without worying that some piece of code reconfigures the Executor to use 23 Threads and thereby killing your machine.

Jens Schauder
+2  A: 

I guess it means that only one thread is processing the tasks, and there is no way to add more threads after the creation

Maurice Perry