nerdexam
Oracle

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…

Use Concurrency API in Java EE 7 Applications

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)
  • A
    70% (14)
  • B
    5% (1)
  • C
    15% (3)
  • D
    10% (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 - ManagedExecutors is a utility class for wrapping tasks with identity context or ManagedTaskListener callbacks, 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

#ManagedExecutorService#thread pool configuration#Concurrency API#portable configuration

Community Discussion

No community discussion yet for this question.

Full 1Z0-900 Practice