Specifying what thread to execute

Hi There,

I am learning about the new concurrent package in 1.5 and I think its great.

There are times though where I would like to specify the thread that is to be used to execute a particular task. For example, it would be great if I could do the following:

ExecutorService threadExecutor = Executors.newFixedThreadPool(4);

threadExecutor.execute(task1, 0);// always use "Thread0" to execute this

threadExecutor.execute(task2, 1);// always use "Thread1" to execute this

threadExecutor.execute(task3, 2);// always use "Thread2" to execute this

threadExecutor.execute(task4, 3);// always use "Thread3" to execute this

The example above is simplistic to illustrate the wished for API call. I do need this functionality over the course of a run of the application I am currently working on. Do I need to forget about the high level API and go low level on this one?

thanks a lot,

- Paul.

[1080 byte] By [PaulNolana] at [2007-11-26 19:01:10]
# 1
The ThreadExecutor uses a single queue so there's no way to distiguish threads in the pool. The thread you wanted could be busy.You could simply use a separate Executor with one thread for each.
malcolmmca at 2007-7-9 20:44:31 > top of Java-index,Java Essentials,Java Programming...
# 2
okay, thanks for the reply.
PaulNolana at 2007-7-9 20:44:31 > top of Java-index,Java Essentials,Java Programming...