• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Help Beginner

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I would like to run x times the same job to test the system performance so multiple jobs run at the same time.

Can anyone help me, I'm just a beginner.

Thx
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hye J.

Why do u need threads to run a same job x times??

You can do it in a simple way something like this:



This looks very simple



Regards
Sandeep
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to run the jobs simultaneously you would want the Job class to extend the Thread class or implement Runnable class. The work of the job would be in the public void run method.

Example

public class Job extends Thread {
public void run() {
// place work here
}
}

Then you could run a loop which starts up all those jobs to run at once

class JobRunner{

public static void main(String argument[]){

int x= 1000;

for(int i=0; i<x; i++){

Job job = new Job();
job.start();

}

}

}
 
    Bookmark Topic Watch Topic
  • New Topic