• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

running two processess simultaneously

 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i've made two modules in java to complete my project. I want to run my two modules simultaneously. I've called these two modules from a third java program , which calls the two java modules( .jar files)
with the two Runtime Processess(i.e. p1 and p2).
Supposed code :

The problem is that, the second process executes only when the first process is completed ie.when the first module completes. Whereas i want to call these two processess p1 and p2 simultaneously, so that they can keep running and inducing their own results.
i've also tried this with multiple threading too, but the problem is intact.
I guess this sort of problem requires Multiple processing sort of solution.i've dug that concept on google but didn't find something fruitfull.Post some helpfull links if available and implementable.
Kindly reply with the short samples if possible. Thanks in advance.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've also tried this with multiple threading too, but the problem is intact.

How did you do ? There shouldn't be any problem launching them using multiple threads.
 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code of third Java programm calling the two modules using threads :
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought you wanted to execute two Java applications. What are module1 and module2 ? Scripts ?
 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes sir, you are right. module1 and module2 are two java applications i.e. two .jar files.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you need to use rt.exec ? You could instantiate the main class and run its main method instead.
 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That won't matter i guess. Kindly write the code sample what you wanna say exactly , may b i might not b getting clear what u'r saying.The main problem is, i want to call these two modules to execute simultaneously and not one by one.
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vazzdoin Rocko wrote:The problem is that, the second process executes only when the first process is completed ie.when the first module completes.

That shouldn't be the case. It should be possible to use this technique to run the processes concurrently. Unfortunately, your code shown later does not achieve this. The primary problem is you've got all that code running inside the "testing" constructor, not inside the run() method. That means that it all gets run as part of the one main thread that starts everything - not as part of a separate thread that actually runs concurrently with other things. To achieve the latter, you need to put the code inside the run() method, not the constructor. The run() method is the part that gets run in a separate thread.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To achieve the latter, you need to put the code inside the run() method, not the constructor.

I didn't even look at this
 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohkk .. i guess i have tried that earlier .. but not sure. Let's c this time , i should try it now and test if it works fine and let you know. Thanks !!
 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having some errors in the code after modifications.. I guess i have some sytax errors. Cud you please make the modifications in the above code and help me to write the correct code. thanks.
 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yoohooo... It worked .. !! either of my processes are running simultaneousy now. Thanks Mike Simmons , thanks Christophe Verré for your assistance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic