SHARE
    TWEET
    ferrybig

    windows time accuracy using System.timeMilies

    Feb 4th, 2016
    512
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    Java 0.66 KB | None | 0 0
    1. import java.util.stream.LongStream;
    2. /**
    3. *
    4. * @author Ferrybig
    5. */
    6. public class TimeMilies {
    7. public final static boolean USE_SLEEPING_THREAD = true;
    8. public final static boolean USE_DISTINCT = true;
    9. public static void main(String... args) {
    10. if (USE_SLEEPING_THREAD) {
    11. Thread t = new Thread(() -> {
    12. try {
    13. Thread.sleep(Long.MAX_VALUE);
    14. } catch (InterruptedException ex) {
    15. Thread.currentThread().interrupt();
    16. }
    17. });
    18. t.setDaemon(true);
    19. t.start();
    20. }
    21. LongStream s = LongStream.generate(System::currentTimeMillis);
    22. if (USE_DISTINCT) {
    23. s = s.distinct();
    24. }
    25. s.limit(50).forEach(System.out::println);
    26. }
    27. }
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /