callable tasks, simple thread pool set-up, shutdown, awaitTermination

What you added to task queue should not be a simple POJO or java bean. It needs a run() or call() method.

public class DualThreadPool {
//* Construct a thread pool (size 2) with an internal unbounded queue
private final ExecutorService eService = Executors.newFixedThreadPool(2);
private void addTask(Callable task) {
assert task != null;
public static void main(String adfs32[]) throws FileNotFoundException, InterruptedException {
DualThreadPool pool = new DualThreadPool();
pool.addTask(new FileParserTask("<a href="" target="_blank"></a>", ""), true));
pool.addTask(new FileParserTask(new FileReader("c:/windows/ie7.log")));
pool.eService.awaitTermination(22, TimeUnit.SECONDS);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s