0

Hi,

I need to create a time delay before I call a method.

public void brewDrink(CoffeeMachine coffeemachine) {
        try {
            coffeemachine.displayDrinkBrewing();
            Thread.sleep(7000);
            setDrinkReady(coffeemachine);
        } catch (InterruptedException ex) {
        }
    }

This doesn't work, the method isn't called. Any help or pointers are welcome!

5
Contributors
5
Replies
8
Views
7 Years
Discussion Span
Last Post by verruckt24
0

I'm looking trough the API doc and I don't really understand how to implement it... I didn't find any really helpful tutorials, do you know about any?

0

This doesn't work, the method isn't called. Any help or pointers are welcome!

What makes you think the method isn't being called? I would guess that it takes about 7 seconds for that whole method to finish - and it only updates the display after it's done.

If my guess is correct, read this thread from a couple of days ago: http://www.daniweb.com/forums/thread241390.html

0

Thread.currentThread().sleep(1000);//sleep for 1000 ms

Thanks that was particularly helpful, especially because the Java guys haven't put a word about it anywhere in the docs.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.