简体   繁体   中英

how can i make multi-threaded application distributed in java?

I am building a RESTful web service in java using JAX-RS and jersey and deploying it in Tomcat 7.0. In the back-end, there are entities which wrap the database objects, DAOs to manipulate the database, and processing package which contains a scheduler and threads to execute different types of tasks (currently, I have four tasks). I want to make the project distributed (for example running each task (thread) on a different machine), how this can be done? and which technologies and tools i need?

I want to make the project distributed (for example running each task (thread) on a different machine) how this can be done?

Threads run on a single process which lives in one single machine, splitting threads across several machines is not possible. You should have several processes instead. These processes can interact with each other via inter-process communication means such as RMI, Sockets... (have a look at this article for more information)

In 10 words or less? there are many issues here. Maybe to get you started - think about running everything on each machine - how are tasks distributed to the various machines? is there an uber-distributor doling out tasks to machines (via some inter-machine communication path)? or do the schedulers work off a shared data object, ie, some database data - with all of the synchronization issues of reading/writing shared data. what is the 'output' of these tasks? do they control something or do they have results that have to be transmitted to a common place or both?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM