Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Framework for managing Tasks

my question is, whether there exists a framework in Java for managing and concurrently running Tasks that have logical dependencies.

My Task is as follows: I have a lot of independent tasks (Let's say A,B,C,D...), They are implemented as Commands (like in Command pattern). I would like to have a kind of executor which will accept all these tasks and execute them in a parallel manner. The tasks can be dependent one on another (For example, I can't run C, Before I run A), synchronous or asynchronous.

I would also like to incorporate the custom heuristics to affect the scheduler execution, for example if tasks A and B are CPU-intensive and C is, say, has high Memory consumption, It makes sense to run A and C in parallel, rather than running A and B.

Before diving into building this stuff by myself (i'm thinking about java.util.concurrent + annotation based constraints/rules), I was wondering, if someone could point me on some project that could suit my needs. Thanks a lot in advance

like image 765
Mark Bramnik Avatar asked Feb 06 '11 09:02

Mark Bramnik


People also ask

Is Java a framework or language?

What is Java? Java is an object-oriented programming (OOP) language that's been used since 1995. Developers use Java to program applications to work within the boundaries of the domain they're in.


1 Answers

I don't think that a there is a framework for managing tasks that could fulfill your requirements. You are on the right path using the Command pattern. You could take a look at the Akka framework for a simplified concurrency model. Akka is based on the Actor model:

The actor model is another very simple high level concurrency model: actors can’t respond to more than one message at a time (messages are queued into mailboxes) and can only communicate by sending messages, not sharing variables. As long as the messages are immutable data structures (which is always true in Erlang, but has to be a convention in languages without means of ensuring this property), everything is thread-safe, without need for any other mechanism. This is very similar to request cycle found in web development MVC frameworks. http://metaphysicaldeveloper.wordpress.com/2010/12/16/high-level-concurrency-with-jruby-and-akka-actors/

Akka is written in Scala but it exposes clean Java API.

like image 151
Luciano Fiandesio Avatar answered Sep 29 '22 22:09

Luciano Fiandesio