Add synchronization block.

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@411701 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrian T. Co 2006-06-05 07:36:48 +00:00
parent 490407ed18
commit 33d7070056
1 changed files with 14 additions and 5 deletions

View File

@ -129,7 +129,10 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
// Compute for the actual duration window of the sampler
long endTime = System.currentTimeMillis() + duration - rampDownTime;
try {
Thread.sleep(rampUpTime);
try {
Thread.sleep(rampUpTime);
} catch (InterruptedException e) {
}
// Let's reset the throughput first and start getting the samples
for (Iterator i=perfClients.iterator(); i.hasNext();) {
@ -138,14 +141,18 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
}
while (System.currentTimeMillis() < endTime && !stop.get()) {
Thread.sleep(interval);
try {
Thread.sleep(interval);
} catch (InterruptedException e) {
}
sampleClients();
sampleIndex++;
}
} catch (InterruptedException e) {
} finally {
isRunning.set(false);
isRunning.notifyAll();
synchronized (isRunning) {
isRunning.notifyAll();
}
}
}
@ -161,7 +168,9 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
public void waitForSamplerToFinish(long timeout) {
while (isRunning.get()) {
try {
isRunning.wait(timeout);
synchronized (isRunning) {
isRunning.wait(timeout);
}
} catch (InterruptedException e) {
}
}