module Thread:sig
..end
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. | *) |
val max_priority : int32
val min_priority : int32
val norm_priority : int32
type
t
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
val get_id : t -> int64
val get_name : t -> string
val get_priority : t -> string
val get_state : t -> state
val get_thread_group : t -> ThreadGroup.t option
None
if the thread has terminated
its execution.val interrupt : t -> unit
val interrupted : unit -> bool
false
.val is_alive : t -> bool
val is_daemon : t -> bool
val is_interrupted : t -> bool
val join : t -> unit
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
Raises Invalid_argument
if the thread has already been started.
val set_name : t -> string -> unit
val set_priority : t -> int32 -> unit
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
Raises Invalid_argument
if the thread has already been started.
val yield : unit -> unit