Module Thread

module Thread: sig .. end
Threads.

type state = 
| New (*The thread has not been started.*)
| Runnable (*The thread is executing.*)
| Blocked (*The thread is blocked on a lock.*)
| Waiting (*The thread is waiting for another thread (with no timeout).*)
| Timed_waiting (*The thread is waiting for another thread (with a timeout).*)
| Terminated (*The thread has terminated execution.*)
The type of thread states.
val max_priority : int32
The maximum priority for a thread.
val min_priority : int32
The minimum priority for a thread.
val norm_priority : int32
The normal (i. e. default) priority for a thread.
type t 
The type of threads. If a thread raises an exception escapes, it is written to the standard output and then discarded.
val make : ThreadGroup.t option -> string option -> ('a -> unit) -> 'a -> t
make g n f x returns a new thread in group g with name n. The thread will execute f x when started.
val current_thread : unit -> t
Returns the thread that is currently executing.
val get_id : t -> int64
Returns the thread identifier. The identifier is positive, and guaranteed to be unique while the thread is executing. The identifier can be recycled when the thread has terminated its execution.
val get_name : t -> string
Returns the name of the thread.
val get_priority : t -> string
Returns the priority of the thread.
val get_state : t -> state
Returns the state of the thread.
val get_thread_group : t -> ThreadGroup.t option
Returns the group of the thread, None if the thread has terminated its execution.
val interrupt : t -> unit
Interrupts the thread.
val interrupted : unit -> bool
Tests whether the current thread has been interrupted, and sets its interrupted status to false.
val is_alive : t -> bool
Tests whether the thread has started and not terminated.
val is_daemon : t -> bool
Tests whether the thread is a daemon one.
val is_interrupted : t -> bool
Tests whether the thread has been interrupted.
val join : t -> unit
Waits for the termination of the passed thread.

Raises Runtime.Interrupted if the thread is interrupted.

val join_time : t -> int64 -> unit
join_time t m is similar to join t, except that the current thread will at most wait for m milliseconds.

Raises Invalid_argument if m is invalid.

Raises Runtime.Interrupted if the thread is interrupted.

val join_time_nanos : t -> int64 -> int32 -> unit
join_time t m n is similar to join t, except that the current thread will at most wait for m milliseconds plus n nanoseconds.

Raises Invalid_argument if m or n is invalid.

Raises Runtime.Interrupted if the thread is interrupted.

val set_daemon : t -> bool -> unit
Changes the daemon status of the thread.

Raises Invalid_argument if the thread has already been started.

val set_name : t -> string -> unit
Changes the name of the thread.
val set_priority : t -> int32 -> unit
Changes the priority of the thread.

Raises Invalid_argument if the priority is invalid.

val sleep : int64 -> unit
sleep m waits for m milliseconds.

Raises Invalid_argument if m is invalid.

Raises Runtime.Interrupted if the thread is interrupted.

val sleep_nanos : int64 -> int32 -> unit
sleep m n waits for m milliseconds plus n nanoseconds.

Raises Invalid_argument if m or n is invalid.

Raises Runtime.Interrupted if the thread is interrupted.

val start : t -> unit
Starts the execution of the thread.

Raises Invalid_argument if the thread has already been started.

val yield : unit -> unit
Indicates that the current thread wants to yield its use of a processor.