UPDATE: I have used a mix of the answers by extraneon and Jarrod Roberson.
I have currently four methods that I want to run at same time. They are four queries to database.
I need to implement four classes, each one with a run()
with the desired query or there another way to do this?
EDIT: These methods will update statistics in the program and are implemented in a class called StatisticsDB (these methods below are from the Facade because the methods are greater than this). I have a class that will update the statistics that run in a thread in backgroud. I want something like this and can be one connection per thread.
public void updateStatistics(){
//these methods running at same time
pages = getQuantityVisitedPages();
links = getQuantityFoundLinks();
blinks = getQuantityBrokenLinks();
flinks = getQuantityFilteredLinks();
}
public String getQuantityVisitedPages(Connection conn) {
statisticsDB = new StatisticsDB();
return statisticsDB.getQuantityVisitedPages(conn);
}
public String getQuantityFoundLinks(Connection conn) {
statisticsDB = new StatisticsDB();
return statisticsDB.getQuantityFoundLinks(conn);
}
public String getQuantityBrokenLinks(Connection conn) {
statisticsDB = new StatisticsDB();
return statisticsDB.getQuantityFilteredLinks(conn);
}
public String getQuantityFilteredLinks(Connection conn) {
statisticsDB = new StatisticsDB();
return statisticsDB.getQuantityFilteredLinks(conn);
}