[ Operating System | Reference Manual | Alphabetic Index ]

# sleep(+Seconds)

The execution of the calling thread is suspended for Seconds number of seconds

Seconds
  Positive number (integer or float).

## Description

sleep/1 causes the calling thread to be suspended for the given number of seconds. Other threads will be unaffected.

### Modes and Determinism

- sleep(+) is det

### Exceptions

(4) instantiation fault
  Seconds is uninstantiated.
(5) type error
  Seconds is not an integer or float.

## Examples

        ?- sleep(0.3).
                             % short sleep
        Yes (0.00s cpu).     % appears after 0.3 seconds.

        ?- sleep(63072000).
                             % long sleep
        Yes (0.00s cpu).     % appears after 2 years.

        ?- engine_create(E,[thread]),
           engine_resume_thread(E, (sleep(3),writeln(sleep_done))),
           writeln(thread_started),
           engine_join(E, block, S).
        thread_started
        sleep_done           % appears after 3 seconds
        Yes (0.00s cpu)

## See Also

alarm / 1, engine_join / 3, stream_select / 3, condition_wait / 2