tony1812
Posts: 354
Joined: Sat Jul 15, 2017 12:40 pm
Location: Boston MA.

python time.sleep(x) in java

Thu Sep 27, 2018 11:39 pm

Hello, in python, when I need to call a delay action, I can use time.sleep(x). What is it in Java?
Thread.sleep() ? Thanks.

User avatar
DougieLawson
Posts: 38755
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: python time.sleep(x) in java

Fri Sep 28, 2018 12:24 am

Is your local Google broken (or is it comatose from celebrating too hard for it's 20th birthday)?

https://stackoverflow.com/questions/241 ... ay-in-java
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

tony1812
Posts: 354
Joined: Sat Jul 15, 2017 12:40 pm
Location: Boston MA.

Re: python time.sleep(x) in java

Fri Sep 28, 2018 10:21 am

Please don't give me the attitude. I did google it, I read the same post. but My little understanding is Thread.sleep() has something to do with a thread.. I am wondering if it can be applied to general purpose like time.sleep() in python.

I am not a genius like you. Java is brand new to me.

JosAH
Posts: 66
Joined: Sat Nov 12, 2016 2:11 pm
Location: Voorschoten

Re: python time.sleep(x) in java

Fri Sep 28, 2018 3:05 pm

tony1812 wrote:
Fri Sep 28, 2018 10:21 am
Please don't give me the attitude. I did google it, I read the same post. but My little understanding is Thread.sleep() has something to do with a thread.. I am wondering if it can be applied to general purpose like time.sleep() in python.

I am not a genius like you. Java is brand new to me.
The sleep() method in the Thread class is a static method and has nothing to do with any Thread in particular; you can use it and it makes your curent fall to sleep. The method can be interrupted (not very likely) but you have to embed it in a try ... catch block.

kind regards,

Jos

Return to “Java”