In my Main Class I'm calling the Runnable Class Browser multiple times with an URL using blockingQueue.offer(..), which is linked to my
ThreadPoolExecutor pool =
new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS,
blockingQueue, new ThreadPoolExecutor.AbortPolicy());
To see if it's working as desired, I'm caling a loop with
System.out.println("Currently executing threads: "+ pool.getActiveCount());
and I am getting 5 in most cases (except at the beginning when not 5 threads have started yet, which is also fine).
The browser class also has a notification at the beginning, for me to see which URL has been now used. What really grinds my gears is, when I execute the code, I get a notification from all browsers with their URLS, around 60.
My question is, is the ThreadPoolExecutor initiating every task/thread and then putting on hold or freezing? Because I would rather expect 5 browsers notifying their start until one finishes and a new one starts. Is my expectation wrong?
Browser Class:
public class Browser implements Runnable {
public Browser(URL webPage, ArrayList<String> proxyListMain, ArrayList<String> proxyListDetail, String division)
throws IOException {
this.webPage = webPage;
this.proxyListMain = proxyListMain;
this.proxyListDetail = proxyListDetail;
this.division = division;
System.out.println("Browser: " + webPage);
}
@Override
public void run() {...}
...}