Execution#
How Project#evaluateWith scores candidates: one after another, or on worker threads. Get an instance from Execution.sequential() or Execution.parallel(...). Both modes return the same results.
Declaration#
;
Execution has no public constructor. Instances are immutable.
Fields#
| Field | Type | Description |
|---|---|---|
isParallel |
boolean |
true for an instance made by parallel, false for sequential(). public final. |
threads |
Integer |
The thread count passed to parallel. null means the processor count, and it's always null for sequential(). public final. |
Static methods#
sequential#
public static Execution
Scores one candidate after another on the calling thread. It's what Project#evaluate uses.
Returns: an Execution with isParallel == false.
parallel#
public static Execution
public static Execution
Scores candidates on a fixed thread pool with at most threads workers. Results and their order are the same as with sequential(). For pool size, memory use and error order, see Project#evaluateWith.
Parameters
| Name | Type | Description |
|---|---|---|
threads |
Integer |
Optional. The maximum number of worker threads. null, or the no-argument overload, uses Runtime.getRuntime().availableProcessors(). |
Returns: an Execution with isParallel == true.
Errors: throws IllegalArgumentException (unchecked) when threads is 0 or negative.
Example#
Score two candidates on up to four threads.
;
;
Related#
Project#evaluateWith- the call that takes an execution modeEvaluateResult- the result, the same in both modes- Evaluating alternatives - when parallel evaluation pays off
- Call from async code - scoring candidates on several cores from a server