Why aren't my threads start at the same time? Java

Posted by Ada on Stack Overflow See other posts from Stack Overflow or by Ada
Published on 2010-12-27T19:35:01Z Indexed on 2010/12/27 19:54 UTC
Read the original article Hit count: 178

Filed under:
|

Hi, I have variable number of threads which are used for parallel downloading. I used this,

for(int i = 0; i< sth; i++){
       thrList.add(new myThread (parameters));
       thrList.get(i).start();
       thrList.get(i).join();

}

I don't know why but they wait for each other to complete. When using threads, I am supposed get mixed print outs, since right then there are several threads running that code. However, when I print them out, they are always in order and one thread waits for the previous one to finish first. I only want them to join the main thread, not wait for each other. I noticed that when I measured time while downloading in parallel.

How can I fix this? Why are they doing it in order?

In my .java, there is MyThread class with run and there is Downloader class with static methods and variables. Would they be the cause of this? The static methods and variables?

How can I fix this problem?

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading