Global Positioning System Reference
In-Depth Information
Since the ROAF aims at systems of larger scale, the server should use
a more general approach to set of a large number of client calls with a
decent response time. A worker queue or worker thread is a general term
for a sequential chain of tasks usually worked of in one thread. This
could be useful for the sequential order of rounds and moves in a board
game. Another approach is a thread pool, which creates a (given) number
of (worker) threads waiting to process a number of client calls in parallel.
This solution is faster than a single worker queue, although the calls are
processed without a specified order.
Java 1.5 has integrated the java.util.concurrent package to decouple
task definition and task execution for general server programming.
TheJavaTutorial>EssentialClasses>Executors
. . . there's a close connection between the task being done
by a new thread, as defined by its Runnable object, and the
thread itself, as defined by a Thread object. This works well
for small applications, but in large-scale applications, it makes
sense to separate thread management and creation from the
rest of the application. Objects that encapsulate these func-
tions are known as executors.
The java.util.concurrent package basically separates the creation and
execution of tasks with the Executor and ExecutorService interfaces. A
task is a well-defined unit of work like a server request, ideally independent,
while interfaces separate what and how of the general consumer-producer
pattern.
By programming the server application against these interfaces, the ac-
tual scheduling and load balancing can be chosen at deployment time. The
choice depends on hardware considerations, like the number of CPUs, and
expected throughput and responsiveness of the application. Today even
most personal computers operate on multiple processors. With the concur-
rent package, the service can be added to the ROServer as a member:
private int nrOfParallelThreads = 5;
protected ExecutorService executorService
= Executors.newFixedThreadPool( nrOfParallelThreads );
The fixed thread pool is supplied as a default service for testing on the
programming environment while the extending ROApp can override the
initial choice with an adequate implementation. The choices to scale the
server at deployment time can be a sequential (un)bounded worker queue
or a parallel thread pool of queues.
For sequential and unbounded task
processing the choice could be:
 
Search WWH ::




Custom Search