File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes Thread pools, paced and exclusive tasks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread pools, paced and exclusive tasks" Watch "Thread pools, paced and exclusive tasks" New topic

Thread pools, paced and exclusive tasks

Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
I have a thread pool that I've created to handle some background processing in my app. I have three kinds of tasks that I need to run.

1. Normal task. This works correctly.

2. Paced task. This task can run concurrent with others, but can only run so often. I need it to play nice and not run multiple jobs at the same time.

3. Exclusive task. Only one of these can be running at a time. If a second gets added to the queue, it needs to interrupt the first one and take over.

Is there a way to handle this without making separate thread pools for each task? Or writing a custom ExecutorService?
I agree. Here's the link:
subject: Thread pools, paced and exclusive tasks
Similar Threads
thread pooling
Multiple Thread Pool Framework - HowTo
Thread-based timer versus Timer Class-based timer
How to set thread name when using Future/FutureTask mechanism
How can I serialize thread handling with Java 5's java.util.concurrent package?