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.lbcore_155;
015
016import org.slf4j.Logger;
017import org.slf4j.LoggerFactory;
018
019/**
020 * @author Ceki Gülcü
021 */
022public class OThread extends Thread {
023
024    static int NANOS_IN_MILLI = 1000 * 1000;
025
026    static int WAIT_MILLIS = 10;
027
028    Logger logger = LoggerFactory.getLogger(this.getClass());
029
030    public void run() {
031
032        while (!isInterrupted()) {
033            long start = System.nanoTime();
034            for (long now = System.nanoTime(); now < start + 2 * WAIT_MILLIS * NANOS_IN_MILLI; now = System.nanoTime()) {
035                logger.info("in time loop");
036            }
037
038            logger.info("before 2nd sleep");
039
040            try {
041                sleep(1000);
042            } catch (InterruptedException e) {
043                logger.info("While sleeping", e);
044                e.printStackTrace();
045                break;
046            }
047            logger.info("after sleep");
048        }
049        logger.info("exiting WHILE");
050
051    }
052}