To add to this answer: Executing the command (su ) in the background and immediately wait ing for it can be useful when using set -e and writing conditions whose code should still have set. This function below doesn't work like i want it to;

I need it to wait 5 seconds before checking whether the newstate is -1. Currently, it doesn't wait, i If you want a no busy wait for lua for use in frames for videogames or applications, perhaps wxlua or other libraries may provide less resource craving sleep functions. The sleep function. What is the difference between a wait() and sleep() in threads? Is my understanding that a wait() -ing thread is still in running mode and uses cpu cycles but a sleep() -ing does not consume. There are several ways of doing this, but why do you need to add a delay?

What is the difference between a wait() and sleep() in threads? Is my understanding that a wait() -ing thread is still in running mode and uses cpu cycles but a sleep() -ing does not consume. There are several ways of doing this, but why do you need to add a delay? If we knew then we'd be able to suggest the most appropriate way to do it.