beetlebug▾
/

thread attach

Puts a detached channel in the calling thread.

thread::attach CHANNEL

Description

The command thread::attach is the second half of thread::transfer: it puts CHANNEL, which a thread::detach took out of a thread of the group, in the calling thread with the same name. The examples of this page run with --allow thread --allow channels,file.

Arguments

ArgumentTypeDefaultDescription
CHANNELchannel namerequiredA detached channel.

Returns

An empty string.

Examples

% set f [open note.txt w]
> thread::detach $f
> thread::attach $f
> puts -nonewline $f hi
> close $f
> file size note.txt
2

Errors

% thread::attach
wrong # args: should be "thread::attach channel"
-errorcode TCL WRONGARGS

% thread::attach nochan
channel not detached
-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

See also