[concurrency-interest] Problem in customizing the Executor framework behaviour

A Shahkar a.shahkar at ieee.org
Wed Jul 15 02:27:44 EDT 2009

Dear all,

I'm developing a small framework which is intended to be used to
simulate random requests on custom protocols against server
applications. The following classes and interfaces are used to generate
random requests which probably meet certain requirements enforced by
the protocol.

public interface Randomizer<T> {
public T randomize();
public class ProtoRequestRandomizer implements Randomizer<ProtoRequest> {
// Generates random requests which meet Proto requirements
public interface RequestResource {
// Supplies requests to be sent by client simulators.
public Request getRequest();
public class MyRequestResource implements RequestResource {
public RequestResource(Randomizer<? extends Request> randomizer) {
    // ...
public synchronized Request getRequest() {
// Generates a request using the supplied randomizer. It may simply call
// randomize() or pick one from a collection of randomized requests.
// If the collection is thread-safe, this method need not to be
There will be a Runnable or a Callable, which fetches a request
provided by a RequestResource and sends it to a specified target.
Something like this:

public class BlindRequestTask implements Runnable {
public BlindRequestTask(RequestResource resource, Target target) {
// ...
public void run() {
// Fetches a request (or a sequence of requests) from the specified RequestResource and sends it to the target, likely on a network.
I want to use a thread pool created by the executor framework to send a
total number of N requests (or N sequences of requests, whatever the
sending task does) against a target. There is not N different tasks as
you see, there's only one task which should be executed N times by
multiple threads in a thread pool. However every time the task
executes, the request is a different one which is got from the request
resource. N can be a very big number, something around a few ten thousands.

The code should also be able to keep executing the task until
shut down. Also, I want every thread to wait for a fixed delay before
executing the repeated task again. It makes me able to reduce the load
on the target if necessary. How can I achieve this? I'm searching for the most (or a very) efficient solution.

I thought it would be good to supply a customized ArrayBlockingQueue which returns the same task for N times to an executor. But I could not proceed any further because I don't know exactly which methods should be overriden, whether it is an efficient solution, and how can I add the delay feature.

Any other comments are also highly appreciated.

Thanks in advance.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20090714/0693c8e3/attachment.html>

More information about the Concurrency-interest mailing list