1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.issue.lbcore_155;
15
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19
20
21
22 public class OThread extends Thread {
23
24 static int NANOS_IN_MILLI = 1000 * 1000;
25
26 static int WAIT_MILLIS = 10;
27
28 Logger logger = LoggerFactory.getLogger(this.getClass());
29
30 public void run() {
31
32 while (!isInterrupted()) {
33 long start = System.nanoTime();
34 for (long now = System.nanoTime(); now < start + 2 * WAIT_MILLIS * NANOS_IN_MILLI; now = System
35 .nanoTime()) {
36 logger.info("in time loop");
37 }
38
39 logger.info("before 2nd sleep");
40
41 try {
42 sleep(1000);
43 } catch (InterruptedException e) {
44 logger.info("While sleeping", e);
45 e.printStackTrace();
46 break;
47 }
48 logger.info("after sleep");
49 }
50 logger.info("exiting WHILE");
51
52 }
53 }