001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.classic.issue.lbclassic135.lbclassic139; 015 016import org.junit.Before; 017import org.junit.Test; 018 019import ch.qos.logback.classic.BasicConfigurator; 020import ch.qos.logback.classic.LoggerContext; 021 022public class LB139_DeadlockTest { 023 024 LoggerContext loggerContext = new LoggerContext(); 025 026 @Before 027 public void setUp() { 028 loggerContext.setName("LB139"); 029 BasicConfigurator bc = new BasicConfigurator(); 030 bc.setContext(loggerContext); 031 bc.configure(loggerContext); 032 } 033 034 @Test 035 // (timeout=3000) 036 public void test() throws Exception { 037 Worker worker = new Worker(loggerContext); 038 Accessor accessor = new Accessor(worker, loggerContext); 039 040 Thread workerThread = new Thread(worker, "WorkerThread"); 041 Thread accessorThread = new Thread(accessor, "AccessorThread"); 042 043 workerThread.start(); 044 accessorThread.start(); 045 046 int sleep = Worker.SLEEP_DUIRATION * 10; 047 048 System.out.println("Will sleep for " + sleep + " millis"); 049 Thread.sleep(sleep); 050 System.out.println("Done sleeping (" + sleep + " millis)"); 051 worker.setDone(true); 052 accessor.setDone(true); 053 054 workerThread.join(); 055 accessorThread.join(); 056 } 057}