In my ScrapingISA class i have multiple Methods. I want to call each Method in a single Thread (concurrently). Goal: make everything faster (since im using Selenium for each method with a implicit-wait of 3 seconds)
openThreads() is my Method which gets all necessary Methods (all methods starts with "get" and its length are bigger than 6 chars, so in total I get 7 methods, which is correct) which id like to call concurrently:
private void openThreads() {
Method[] methods = this.getClass().getDeclaredMethods();
for(Method method: methods) {
if(method.getName().startsWith("get") && method.getName().length() > 6) {
new Thread(new Runnable() {
public void run() {
ScrapingISA scraping = new ScrapingISA(kurzzeichen, passwort);
try {
method.invoke(scraping);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
}
}).start();
}
}
}
I also debugged it and somehow the methods don't get invoked at all, neither of them! What am I missing? I'd appreciate any help! ... I was so lost that I even tried to sys-out some stuff after the invocation... but nothing was written in the console..
Aucun commentaire:
Enregistrer un commentaire