Don't call stopped.get() outside the lock.

This commit is contained in:
akwizgran
2011-09-27 16:26:55 +01:00
parent a40c081815
commit dea77b22d7

View File

@@ -29,11 +29,12 @@ class DatabaseCleanerImpl implements DatabaseCleaner, Runnable {
public void run() { public void run() {
try { try {
while(!stopped.get()) { while(true) {
if(callback.shouldCheckFreeSpace()) { if(callback.shouldCheckFreeSpace()) {
callback.checkFreeSpaceAndClean(); callback.checkFreeSpaceAndClean();
} else { } else {
synchronized(stopped) { synchronized(stopped) {
if(stopped.get()) break;
try { try {
stopped.wait(msBetweenSweeps); stopped.wait(msBetweenSweeps);
} catch(InterruptedException ignored) {} } catch(InterruptedException ignored) {}