+ while (isActive()) {
+ Iterator<Thread> it = threads.iterator();
+ while (it.hasNext()) {
+ Thread thread = it.next();
+ if (!thread.isAlive() && isActive()) {
+ if (activeSessions.containsKey(thread.getId())) {
+ Session session = activeSessions
+ .get(thread.getId());
+ activeSessions.remove(thread.getId());
+ session.logout();
+ if (log.isDebugEnabled())
+ log.debug("Cleaned up JCR session (userID="
+ + session.getUserID()
+ + ") from dead thread "
+ + thread.getId());
+ }
+ it.remove();
+ }
+ }
+
+ synchronized (ThreadBoundJcrSessionFactory.this) {
+ try {
+ ThreadBoundJcrSessionFactory.this.wait(1000);
+ } catch (InterruptedException e) {
+ // silent
+ }
+ }
+ }