One of the goals of the Liberty core is to have excellent scaling characteristics in multi-core environments. Given the current industry trends, it is clear that single thread performance gains have been minor compared with past improvements. It is also clear that the number of hardware threads supported on newer machines has been increasing rapidly.
While in the past we would have expected single thread performance to roughly double every 18 months, now we expect the number of hardware threads to roughly double every 18 months. With that in mind, Liberty must provide easy to use services that allow users to schedule multiple tasks for parallel execution.
In order to prevent the proliferation of code to manage threads, Liberty has
provided a reference to a java.util.concurrent.ExecutorService
implementation in the OSGi Service Registry. The implementation of the
employs a work stealing scheduler and automatic tuning that attempts to
provide optimal throughput based on the runtime environment and current load.
Since the executor is exposed in the service registry, users can acquire the
service reference using any of the supported OSGi mechanisms. One of the
simplest ways to do this is to use OSGi Declarative Services to define a
component that has a reference to a
java.util.concurrent.ExecutorService
.
The ExecutorService
interface defined by Java allows users to
request execution of multiple tasks in various ways. The most basic of these
is submission of an object that implements the Callable
interface.
A Callable
is an object that declares a call
method
that performs some action and returns a result. When a Callable
is submitted to an executor, the executor returns a handle to the scheduled
work known as a Future
. The Future
instance can then
be used to check the status of the work and get the result.
ExecutorService
documentation for additional
examples.
There is currently no configuration required for the threading services.