public final class RuntimeAvailableProcessors extends Object
Runtime.availableProcessors()
and optionally override its return value.
This class makes the number of available processors configurable for the sake of testing.
override(int)
and resetOverride()
should only be used for testing purposes.
Modifier and Type | Method and Description |
---|---|
static int |
get()
Returns the number of available processors.
|
static void |
override(int availableProcessors)
Overrides the number of available processors returned by the method
get() . |
static void |
overrideDefault(int availableProcessors)
Overrides the number of available processors that are set by the method
override(int) |
static void |
resetOverride()
Resets the overridden number of available processors to
Runtime.availableProcessors() . |
public static int get()
Returned value is either equal to Runtime.availableProcessors()
or an overridden value by call of the method override(int)
.
public static void override(int availableProcessors)
get()
.
This is to be used only for testing.
availableProcessors
- number of available processorspublic static void overrideDefault(int availableProcessors)
override(int)
This is to be used only for testing.
availableProcessors
- public static void resetOverride()
Runtime.availableProcessors()
.
This is to be used only for testing.
Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.