I was wondering if anyone can help me out with a problem.
What I want to accomplish (using Java):
In first iteration, I want to "doStuff" 10 times (concurrently).
In the second iteration, I want to "doStuff" 20 times (in a concurrent manner) AFTER the first iteration is complete.
etc... (I'd like to be able to loop because I plan to do this over 100 times)
The problem with my code is that it's doing stuff 30 times at once. Any help would be greatly appreciated.
PS: Parts of code were removed for simplification so let me know if there are any mistakes.
public static void doStuff(){
[Code]
}
public static void threadThis (int y){
for (int i = 0; i<y; i++) {
Thread t1 = new Thread(){
public void run() {
doStuff();
}
};
t1.start();
}
}
public static void main(String[] agrs) throws InterruptedException {
for (int p = 0; p<21; p = p + 10){
threadThis(p);
}
}
public static synchronized threadThisnot work?