protected static final long THREAD_JOIN_TIMEOUT = 1000;//in ms
@Override
public void removeTabAt(int index) {
TerminalLoggingWindow log = this.getTerminalLoggingWindowAt(index);
TerminalInfo tI = log.gettI();
Thread workingThread=tI.getWorkingThread();
if (null != workingThread) {
workingThread.interrupt();
long start = System.nanoTime();
do {
try {
workingThread.join(THREAD_JOIN_TIMEOUT);
} catch (InterruptedException ex) {
//do nothing
}
} while (System.nanoTime() - start < THREAD_JOIN_TIMEOUT * 1000000);
if (null != workingThread) {
if (workingThread.isAlive()) {
RuntimeException ex = new RuntimeException("Worker thread for " + tI.getTerminal().getName() + "terminal is not responding");
Logger.getLogger(LogTabbedPane.class.getName()).log(Level.SEVERE, null, ex);
}
workingThread = null;
}
}