ferrybig icon

windows time accuracy using System.timeMilies

ferrybig | PRO | 02/04/16 10:31:06 AM UTC | 0 ⭐ | 664 👁️ | Never ⏰ | []
Java |

660 B

|

None

|

0 👍

/

0 👎

import java.util.stream.LongStream;
 
/**
 *
 * @author Ferrybig
 */
public class TimeMilies {
    
    public final static boolean USE_SLEEPING_THREAD = true;
    public final static boolean USE_DISTINCT = true;
    
    public static void main(String... args) {
        if (USE_SLEEPING_THREAD) {
            Thread t = new Thread(() -> {
                try {
                    Thread.sleep(Long.MAX_VALUE);
                } catch (InterruptedException ex) {
                    Thread.currentThread().interrupt();
                }
            });
            t.setDaemon(true);
            t.start();
        }
        LongStream s = LongStream.generate(System::currentTimeMillis);
        if (USE_DISTINCT) {
            s = s.distinct();
        }
        s.limit(50).forEach(System.out::println);
    }
}

Comments