user120513
user120513

Reputation: 531

Controlling number of Threads for ManagedExecutorServices / Java EE 7

In Java SE one can use constructs like

ExecutorService es1 = Executors.newSingleThreadExecutor();
ExecutorService es2 = Executors.newFixedThreadPool(10);

to control the number of threads available to the executor service. In Java EE 7 it's possible to inject executor services:

@Resource 
private ManagedExecutorService mes;

But how can I control the number of threads available to the managed executor service ? For example, in the application I'm writing, there is an executor service that has to be executed in a single thread. So I can't just let the platform choose its preferred number of threads.

Upvotes: 5

Views: 1745

Answers (1)

Eng.Fouad
Eng.Fouad

Reputation: 117589

Actually, this setting should be set in the server settings, through admin console (in GlassFish for example), or during the creation of the service:

asadmin create-managed-executor-service --corepoolsize=10 --maximumpoolsize=20 concurrent/mes

Upvotes: 2

Related Questions