itbeme
asked on
Calling any java method as thread
I have an existing webservices project, with 100+ class files, each one basically runs a query, and return results.
I need to build some new hits that do several various hits asynchronously. Then return data. How can I do this without making a bunch of modifications(or as little as possible) to the various class files. It needs to be done at this webservice level, I can't have the calling applications do the hits asynchronously.
So my visualized solution is something like:
String a =CallAsThread(ClassLoader. SomeClass. getTheseDB Configs(), ClassLoade r.SomeClas s2.getThes eDBConfigs 2()));
Where CallAsThread calls the 2 different classes as threads, joins them, gets and returns there results or however this can be accomplished.
I need to build some new hits that do several various hits asynchronously. Then return data. How can I do this without making a bunch of modifications(or as little as possible) to the various class files. It needs to be done at this webservice level, I can't have the calling applications do the hits asynchronously.
So my visualized solution is something like:
String a =CallAsThread(ClassLoader.
Where CallAsThread calls the 2 different classes as threads, joins them, gets and returns there results or however this can be accomplished.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
To be able to do the way suggested I declared a new thread object passing the Runnable object as a paremeter
Thread t1 = new Thread (new Runnable() {
public void run() {
results1=doThis1();
}
}
);
Thread t2 = new Thread (new Runnable() {
public void run() {
results2=doThis2();
}
}
);
t1.start();
t2.start();
t1.join();
t2.join();
Thanks
Thread t1 = new Thread (new Runnable() {
public void run() {
results1=doThis1();
}
}
);
Thread t2 = new Thread (new Runnable() {
public void run() {
results2=doThis2();
}
}
);
t1.start();
t2.start();
t1.join();
t2.join();
Thanks
>>String a =CallAsThread...
Does this mean that you want the result to be in some way a concatenation of strings that are the results of the independent queries?