View Full Version : Executor class in Java 5?

March 7th, 2009, 07:55 PM
Does anyone know how we can use the Executor class with threads in Java 5?

March 7th, 2009, 09:48 PM
An Executor is normally used instead of explicitly creating threads.

I don't think it is meant to be used with Threads.

EDIT: Actually I just noticed its an interface and two other classes with the word Thread in them implement it:

ThreadPoolExecutor (http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html)

ScheduledThreadPoolExecutor (http://http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html)

March 7th, 2009, 09:50 PM
Very broad question... google for examples, there are tutorials. You should also note that Executor is an interface, not a class. You usually use the factory methods in class Executors to build actual implementations of ExecutorService, and then use those to actually execute stuff.

March 8th, 2009, 03:51 AM
OK, I made a mistake and forgot it is an interface.

Thanks a lot CptPicard for the info, I'll look them up. I am getting an idea that Executor enables concurrent thread behavior.