forked from Archives/Athou_commafeed
shutdown pool when application stops
This commit is contained in:
@@ -27,6 +27,7 @@ import com.commafeed.backend.dao.FeedCategoryDAO;
|
||||
import com.commafeed.backend.dao.FeedDAO;
|
||||
import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
||||
import com.commafeed.backend.dao.UserDAO;
|
||||
import com.commafeed.backend.feeds.FeedRefreshUpdater;
|
||||
import com.commafeed.backend.feeds.FeedRefreshWorker;
|
||||
import com.commafeed.backend.model.ApplicationSettings;
|
||||
import com.commafeed.backend.model.UserRole.Role;
|
||||
@@ -61,6 +62,9 @@ public class StartupBean {
|
||||
@Inject
|
||||
ApplicationSettingsService applicationSettingsService;
|
||||
|
||||
@Inject
|
||||
FeedRefreshUpdater feedRefreshUpdater;
|
||||
|
||||
@Inject
|
||||
Instance<FeedRefreshWorker> workers;
|
||||
|
||||
@@ -145,6 +149,7 @@ public class StartupBean {
|
||||
log.error("interrupted while waiting for threads to finish.");
|
||||
}
|
||||
}
|
||||
feedRefreshUpdater.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,6 +78,17 @@ public class FeedRefreshUpdater {
|
||||
});
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
pool.shutdownNow();
|
||||
while (!pool.isTerminated()) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("interrupted while waiting for threads to finish.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateFeed(Feed feed, Collection<FeedEntry> entries) {
|
||||
pool.execute(new Task(feed, entries));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user