File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
logback-core/src/test/java/ch/qos/logback/core/util Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -67,13 +67,14 @@ public void beforeEach() {
67
67
// see https://jira.qos.ch/browse/LOGBACK-1754
68
68
@ Test
69
69
public void assertNoOverlappingFileLockException () throws IOException {
70
- CountDownLatch latch = new CountDownLatch (THREAD_COUNT );
70
+ CountDownLatch latch = new CountDownLatch (1 );
71
71
List <Thread > threads = new ArrayList <>(THREAD_COUNT );
72
72
for (int i = 0 ; i < THREAD_COUNT ; i ++) {
73
73
LoggerThread thread = new LoggerThread (latch , "message from thread " + i );
74
74
thread .start ();
75
75
threads .add (thread );
76
76
}
77
+ latch .countDown ();
77
78
int i = 0 ;
78
79
for (Thread thread : threads ) {
79
80
try {
@@ -106,13 +107,17 @@ class LoggerThread extends Thread {
106
107
107
108
@ Override
108
109
public void run () {
109
- latch .countDown ();
110
- for (int i = 0 ; i < LOOP_COUNT ; i ++) {
111
- if ((i & 0x08 ) == 0 ) {
112
- // yield to spice it up
113
- Thread .yield ();
110
+ try {
111
+ latch .await ();
112
+ for (int i = 0 ; i < LOOP_COUNT ; i ++) {
113
+ if ((i & 0x08 ) == 0 ) {
114
+ // yield to spice it up
115
+ Thread .yield ();
116
+ }
117
+ PrudentModeTest .this .fa .doAppend (message + " i=" + i );
114
118
}
115
- PrudentModeTest .this .fa .doAppend (message + " i=" + i );
119
+ } catch (InterruptedException ex ) {
120
+ Thread .currentThread ().interrupt ();
116
121
}
117
122
}
118
123
You can’t perform that action at this time.
0 commit comments