Posted By:
Finlay_McWalter
Posted On:
Tuesday, June 12, 2001 06:39 PM
I'm assuming that the only synchronisation between the threads is the monitor that protects doQuery()
If your program is written to look
something like this:
doStuff(){
while(true){
getJobFromSomewhere();
doQuery(); // synchronized
reportResult();
}
}
Then it will (potentially) service all the queries for one thread before allowing another to run. Instead, put a yield() into the loop to allow others that are pending to run:
doStuff(){
while(true){
getJobFromSomewhere();
doQuery(); // synchronized
reportResult();
Thread.yield(); // ADDED
}
}