I have Applications that search page and get a specified number of links. Each link is retrieved by a separate thread. This Simple Code Do this:
public class GetLinkThread implements Runnable {
public int page;
public GetLinkThread(int page) {
this.page = page;
}
@Override
public void run() {
try {
Parser.parseAndAddLinkToSet(page);//this method get links from sites and save to set
} catch (IOException e) {
e.printStackTrace();
}
}
}
In parseAndAddLinkToSet(int page)
method is String root = "www.example.com/" + page;
so I only send the page number to be crawled for links.
And I run this:
ExecutorService executorService = Executors.newCachedThreadPool();
for(int i = 1 ; i < 4 ; i++){//in this case I run 3 threads
executorService.execute(new GetLinkThread(i));
}
executorService.shutdown();
executorService.awaitTermination(1, TimeUnit.HOURS);
I want to make progressbar which when downloading links will show the link that is currently being downloaded by the given thread. I can make progressBar but i don't know how make progressBar which run in background and with another threads.
So my question is, how can I add now a progressBar to my application? ProgressBar which is running when i crawling page and display current page?