001
014
015 package com.liferay.portal.cache.ehcache;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.util.ThreadUtil;
020
021
024 public class ClearEhcacheThreadUtil {
025
026 public static void clearEhcacheReplicationThread()
027 throws InterruptedException {
028
029 Thread[] threads = ThreadUtil.getThreads();
030
031 for (Thread thread : threads) {
032 if (thread == null) {
033 continue;
034 }
035
036 String name = thread.getName();
037
038 if (name.equals(_THREAD_NAME)) {
039 thread.interrupt();
040
041 thread.join(_WAIT_TIME);
042
043 if (thread.isAlive() && _log.isWarnEnabled()) {
044 _log.warn(
045 "Give up waiting on thread " + thread +
046 " after waiting for " + _WAIT_TIME + "ms");
047 }
048 }
049 }
050 }
051
052 private static final String _THREAD_NAME = "Replication Thread";
053
054 private static final long _WAIT_TIME = 1000;
055
056 private static Log _log = LogFactoryUtil.getLog(
057 ClearEhcacheThreadUtil.class);
058
059 }