I’m looking for a Java task scheduler that has a specific feature set before I stumble into developing it myself.
It’s not so much of a scheduler, but a logic gate that determines which tasks in a set (T) can be executed now (e.g. passed off to a ThreadPoolExecutor) and which tasks must wait for some future condition.
This is an example of what I would like to implement: Consider various attributes that might be associated with each task:
- Foo: Foo tasks can only be executed one at a time, so T.foo2 cannot start until T.foo1 has completed, regardless of how much execution capacity there is.
- Bar: Bar tasks have no concurrency limitations, so the scheduler can throw caution to the wind and blast T.bar1 through T.barN directly into the execution queue.
- If a task is marked as having attributes Foo and Bar, then the Foo attribute would take precedence with respect to scheduling.
Simple, right ?
Anyone know of such a framework ?
Thanks !
//Nicholas
Seems to me that you want to use separate executors. You could have a
newFixedThreadPool(1)forFooand thenBarwould usenewCachedThreadPool()if you really wanted to make it unlimited threads.Then you would have some wrapper object so you could
submit(Foo foo),submit(Bar bar), orsubmit(Object obj)which would test forFooorBarand submit it to the right executor. Something like:This assumes that
FooandBarboth implementRunnableorCallable. I also doubt I got the generics right but you get the idea.