Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How do I implement a Timed thread in Java 8?

3192389Mar 7 2016 — edited Apr 13 2016

Hello,

I hope this is the correct forum.  (Java 8?)

Anyway, how would I start to implement this code with Java 8:

    public static void main(String[] args) {
                   
        Wait wait = new Wait(10000); //wait for ten seconds

        try
        {
            wait.StartWait(); //return immediately
            Thread.sleep(11000);
            wait.StopWait();
        }
        catch (Exception ex)
        {
            System.out.print("Timer timed out.");
        }

        System.out.print("Success!");       
    }

Again, I need to return immediately from the StartWait method.

Thank you.

williamj

This post has been answered by Arpit1992 on Apr 13 2016
Jump to Answer

Comments

Post Details

Added on Mar 7 2016
3 comments
1,405 views