Hello All,
I need to make parallel processing with Java. I know there are threads but i need to examine a distributed-like system. I will implement the MST algorithim and with a distributed syncronizer I will merge those sepereted nodes with rounds to find best and minimum spanning tree. This distributed syncronizer will work on different machines each of them connected with their neighbours with a wireless network.

For examining this system, my processes work like nodes in my wireless network area and those will make connections with each other.

For that purpose I should use processes. But I cannot find how to fork these processes, how to kill them, how to wait for them to return to parents.

Please, I need to make this project before next monday.
Thank you, anyway.

So. . are you simulating this process by creating threads on your local machine? Or are you actually using multiple machines and communicating with some master-server that acts to combine the results and to spawn the processes on the other machines? My reply assumes you're simulating it, and only using your local machine. If you were using multiple machines you'd need to put your "spawned" threads software on multiple machines somehow and you'd have to set up your master thread so that it could communicate with all of the other threads (to get their results and to tell them what they need to compute). Anyway, again, this is assuming local machine setup:

http://java.sun.com/docs/books/tutorial/essential/concurrency/sync.html
You should take a look at that. To communicate you can share access to fields but that explains the issues with that. So lets say you have 5 threads that need to return their results, as an Object, to a 6th thread. The 5 threads could update an array with their results (each updating a different index) and then the 6th thread could use this array to combine the results. As far as letting the 6th thread know when it is time to combine the results, check this out:
http://java.sun.com/docs/books/tutorial/essential/concurrency/simple.html
It looks like the isAlive() method will tell you whether or not a thread is finished. P.S., in those links I pointed out to you, you'll notice that it says something about creating a lot of threads, and how instead, you can create WorkerThreads. You might want to take a look at that, although I'm not saying it's needed... just that you should investigate for yourself.

Thank you for your help bu, my instructor says that we need to do this project with processes, but I dont really know how to "fork" a child process in Java as we did in C.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.