beetlebug▾
/

thread exit

Ends the calling thread.

thread::exit ?STATUS?

Description

The command thread::exit ends the calling thread at once, with STATUS as its exit status for thread::join. The default status is 666. A catch cannot stop it. A thread::send that waits for the script that calls it gets the error thread::exit with the code THREAD STOPPED. The main thread cannot end with thread::exit: use exit.

Arguments

ArgumentTypeDefaultDescription
STATUSinteger666The exit status.

Returns

The command does not return.

Examples

% set t [thread::create -joinable {thread::exit 3}]
> thread::join $t
3

% set t [thread::create -joinable {thread::exit}]
> thread::join $t
666

Errors

% thread::exit
the main thread cannot exit with thread::exit
-errorcode NONE

% thread::exit a b
wrong # args: should be "thread::exit ?status?"
-errorcode TCL WRONGARGS

Facts

Capability
thread. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also