1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.issue.lbclassic135.lbclassic139;
15
16 import org.junit.jupiter.api.BeforeEach;
17
18 import ch.qos.logback.classic.BasicConfigurator;
19 import ch.qos.logback.classic.LoggerContext;
20 import org.junit.jupiter.api.Test;
21
22 public class LB139_DeadlockTest {
23
24 LoggerContext loggerContext = new LoggerContext();
25
26 @BeforeEach
27 public void setUp() {
28 loggerContext.setName("LB139");
29 BasicConfigurator bc = new BasicConfigurator();
30 bc.setContext(loggerContext);
31 bc.configure(loggerContext);
32 }
33
34 @Test
35
36 public void test() throws Exception {
37 Worker worker = new Worker(loggerContext);
38 Accessor accessor = new Accessor(worker, loggerContext);
39
40 Thread workerThread = new Thread(worker, "WorkerThread");
41 Thread accessorThread = new Thread(accessor, "AccessorThread");
42
43 workerThread.start();
44 accessorThread.start();
45
46 int sleep = Worker.SLEEP_DUIRATION * 10;
47
48 System.out.println("Will sleep for " + sleep + " millis");
49 Thread.sleep(sleep);
50 System.out.println("Done sleeping (" + sleep + " millis)");
51 worker.setDone(true);
52 accessor.setDone(true);
53
54 workerThread.join();
55 accessorThread.join();
56 }
57 }