1Z0-900 · Question #42
How can you configure, in a portable way, the number of threads used by a ManagedExecutorService?
The correct answer is A. programmatically, using a ManagedExecutorService. Option A is correct because the Jakarta Concurrency specification provides the @ManagedExecutorDefinition annotation (introduced in Jakarta Concurrency 3.0 / Jakarta EE 10), which lets you programmatically declare a ManagedExecutorService with properties like maxAsync to…
Question
How can you configure, in a portable way, the number of threads used by a ManagedExecutorService?
Options
- Aprogrammatically, using a ManagedExecutorService
- Busing the ManagedExecutors utility class to define the execution properties
- CThis cannot be done because this configuration is dependent on the Java EE Product Provider.
- Dconfiguring the thread pool info in the deployment descriptor
How the community answered
(20 responses)- A70% (14)
- B5% (1)
- C15% (3)
- D10% (2)
Explanation
Option A is correct because the Jakarta Concurrency specification provides the @ManagedExecutorDefinition annotation (introduced in Jakarta Concurrency 3.0 / Jakarta EE 10), which lets you programmatically declare a ManagedExecutorService with properties like maxAsync to control concurrency - this is spec-defined and therefore portable across all compliant application servers.
Why the distractors are wrong:
- B -
ManagedExecutorsis a utility class for wrapping tasks with identity context orManagedTaskListenercallbacks, not for defining thread pool properties. - C - The spec explicitly provides portable configuration mechanisms, so this is false; vendor-specific tuning exists but portable options do too.
- D - Deployment descriptors (e.g.,
glassfish-resources.xml,jboss-web.xml) are vendor-specific, making them the opposite of portable.
Memory tip: Match "portable" to "programmatic/annotation-based" in Jakarta EE - just as @DataSourceDefinition portably defines a datasource in code, @ManagedExecutorDefinition portably defines your executor. If the format is a vendor file, it's not portable.
Topics
Community Discussion
No community discussion yet for this question.