thread release
Subtracts one from the reference count of a thread.
thread::release ?-wait? ?ID?
Description
The command thread::release subtracts one from the reference count of the thread ID, or of the calling thread, and gives the new count. The count does not go below 0. At 0, the thread::wait of the thread returns, and the thread ends at the end of its script. A release of the main thread changes its count and does not end it.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| ID | thread id | none | The thread, by default the calling thread. |
Options
| Option | Type | Default | Description |
|---|---|---|---|
-wait | flag | none | Waits for the end of the thread when the count goes to 0. |
-wait
Waits for the end of the thread when the count goes to 0.
When the count goes to 0, the command waits until the thread ends. While it waits, the caller runs the scripts that other threads send to it.
% set t [thread::create]
> thread::release -wait $t
> thread::exists $t
0A flag has no value to check.
Returns
The new reference count.
Examples
% set t [thread::create]
> thread::preserve $t
> thread::preserve $t
> thread::release $t
1
% set t [thread::create]
> thread::release $t
0
Errors
% thread::release tid0x99
thread "tid0x99" does not exist
-errorcode NONE
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