multithreading - Process forking, child processes etc. [Java] -


i need implement vector clocks in small programming exercise , decided use java it. question not related actual algorithm of manipulating vector clocks of processes, how initialize other java applications or child processes relatively easy java program?

my initial plan following: have "main program", decides how many clients/children start , these children/clients should communicate each other , update corresponding vector clocks accordingly. number of clients started depends on number of lines in input file given "main program". elegant way start these client processes? should each take 2 files , integer parameters. files tell (send or advance clock) , integer tells line in configuration file client should pick port number used.

in java, concept of creating concurrent tasks based on threads rather processes. start new process, must typically invoke java multiple times or use processbuilder interface. concurrency in java designed threads, that's i'll recommend try, e.g.,:

public static void main(string[] args) {     int numberofthreads  = ...     for(int = 0; < numberofthreads; i++) {         file f1 = ...         file f2 = ....          int j = ...           new thread(new vectorclock(f1, f2, j)).start();     } }  public class vectorclock implements runnable {     public vectorclock(file file1, file file2, int i) {        // ...     }      @override     public void run() {         // gets executed when invoked threads .start() routine     } } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -