Logo

Programming-Idioms

  • VB
  • D
  • C

Idiom #45 Pause execution for 5 seconds

Sleep for 5 seconds in current thread, before proceeding with the next instructions.

The pedestrian walks, then stays still for 5 seconds, then resumes walking
#include <unistd.h>
usleep(5000000);

usleep argument is in microseconds.
See : man 3 usleep
#include <Windows.h>
Sleep(5000);
System.Threading
System.Threading.Thread.Sleep(5000)
import core.thread;
Thread.sleep(5.seconds);
delay 5.0;

New implementation...
< >
programming-idioms.org