Debian Codegraph @

upstream/opensuse-tumbleweed/man3/threads.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "threads 3pm"
61 .TH threads 3pm 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 threads \- Perl interpreter\-based threads
68 .SH VERSION
69 .IX Header "VERSION"
70 This document describes threads version 2.43
71 .SH WARNING
72 .IX Header "WARNING"
73 The "interpreter\-based threads" provided by Perl are not the fast, lightweight
74 system for multitasking that one might expect or hope for. Threads are
75 implemented in a way that makes them easy to misuse. Few people know how to
76 use them correctly or will be able to provide help.
77 .PP
78 The use of interpreter\-based threads in perl is officially
79 discouraged.
80 .SH SYNOPSIS
81 .IX Header "SYNOPSIS"
82 .Vb 4
83 \& use threads (\*(Aqyield\*(Aq,
84 \& \*(Aqstack_size\*(Aq => 64*4096,
85 \& \*(Aqexit\*(Aq => \*(Aqthreads_only\*(Aq,
86 \& \*(Aqstringify\*(Aq);
87 \&
88 \& sub start_thread {
89 \& my @args = @_;
90 \& print(\*(AqThread started: \*(Aq, join(\*(Aq \*(Aq, @args), "\en");
91 \& }
92 \& my $thr = threads\->create(\*(Aqstart_thread\*(Aq, \*(Aqargument\*(Aq);
93 \& $thr\->join();
94 \&
95 \& threads\->create(sub { print("I am a thread\en"); })\->join();
96 \&
97 \& my $thr2 = async { foreach (@files) { ... } };
98 \& $thr2\->join();
99 \& if (my $err = $thr2\->error()) {
100 \& warn("Thread error: $err\en");
101 \& }
102 \&
103 \& # Invoke thread in list context (implicit) so it can return a list
104 \& my ($thr) = threads\->create(sub { return (qw/a b c/); });
105 \& # or specify list context explicitly
106 \& my $thr = threads\->create({\*(Aqcontext\*(Aq => \*(Aqlist\*(Aq},
107 \& sub { return (qw/a b c/); });
108 \& my @results = $thr\->join();
109 \&
110 \& $thr\->detach();
111 \&
112 \& # Get a thread\*(Aqs object
113 \& $thr = threads\->self();
114 \& $thr = threads\->object($tid);
115 \&
116 \& # Get a thread\*(Aqs ID
117 \& $tid = threads\->tid();
118 \& $tid = $thr\->tid();
119 \& $tid = "$thr";
120 \&
121 \& # Give other threads a chance to run
122 \& threads\->yield();
123 \& yield();
124 \&
125 \& # Lists of non\-detached threads
126 \& my @threads = threads\->list();
127 \& my $thread_count = threads\->list();
128 \&
129 \& my @running = threads\->list(threads::running);
130 \& my @joinable = threads\->list(threads::joinable);
131 \&
132 \& # Test thread objects
133 \& if ($thr1 == $thr2) {
134 \& ...
135 \& }
136 \&
137 \& # Manage thread stack size
138 \& $stack_size = threads\->get_stack_size();
139 \& $old_size = threads\->set_stack_size(32*4096);
140 \&
141 \& # Create a thread with a specific context and stack size
142 \& my $thr = threads\->create({ \*(Aqcontext\*(Aq => \*(Aqlist\*(Aq,
143 \& \*(Aqstack_size\*(Aq => 32*4096,
144 \& \*(Aqexit\*(Aq => \*(Aqthread_only\*(Aq },
145 \& \e&foo);
146 \&
147 \& # Get thread\*(Aqs context
148 \& my $wantarray = $thr\->wantarray();
149 \&
150 \& # Check thread\*(Aqs state
151 \& if ($thr\->is_running()) {
152 \& sleep(1);
153 \& }
154 \& if ($thr\->is_joinable()) {
155 \& $thr\->join();
156 \& }
157 \&
158 \& # Send a signal to a thread
159 \& $thr\->kill(\*(AqSIGUSR1\*(Aq);
160 \&
161 \& # Exit a thread
162 \& threads\->exit();
163 .Ve
164 .SH DESCRIPTION
165 .IX Header "DESCRIPTION"
166 Since Perl 5.8, thread programming has been available using a model called
167 \&\fIinterpreter threads\fR which provides a new Perl interpreter for each
168 thread, and, by default, results in no data or state information being shared
169 between threads.
170 .PP
171 (Prior to Perl 5.8, \fI5005threads\fR was available through the \f(CW\*(C`Thread.pm\*(C'\fR API.
172 This threading model has been deprecated, and was removed as of Perl 5.10.0.)
173 .PP
174 As just mentioned, all variables are, by default, thread local. To use shared
175 variables, you need to also load threads::shared:
176 .PP
177 .Vb 2
178 \& use threads;
179 \& use threads::shared;
180 .Ve
181 .PP
182 When loading threads::shared, you must \f(CW\*(C`use threads\*(C'\fR before you
183 \&\f(CW\*(C`use threads::shared\*(C'\fR. (\f(CW\*(C`threads\*(C'\fR will emit a warning if you do it the
184 other way around.)
185 .PP
186 It is strongly recommended that you enable threads via \f(CW\*(C`use threads\*(C'\fR as early
187 as possible in your script.
188 .PP
189 If needed, scripts can be written so as to run on both threaded and
190 non\-threaded Perls:
191 .PP
192 .Vb 8
193 \& my $can_use_threads = eval \*(Aquse threads; 1\*(Aq;
194 \& if ($can_use_threads) {
195 \& # Do processing using threads
196 \& ...
197 \& } else {
198 \& # Do it without using threads
199 \& ...
200 \& }
201 .Ve
202 .ie n .IP "$thr = threads\->create(FUNCTION, ARGS)" 4
203 .el .IP "\f(CW$thr\fR = threads\->create(FUNCTION, ARGS)" 4
204 .IX Item "$thr = threads->create(FUNCTION, ARGS)"
205 This will create a new thread that will begin execution with the specified
206 entry point function, and give it the \fIARGS\fR list as parameters. It will
207 return the corresponding threads object, or \f(CW\*(C`undef\*(C'\fR if thread creation failed.
208 .Sp
209 \&\fIFUNCTION\fR may either be the name of a function, an anonymous subroutine, or
210 a code ref.
211 .Sp
212 .Vb 5
213 \& my $thr = threads\->create(\*(Aqfunc_name\*(Aq, ...);
214 \& # or
215 \& my $thr = threads\->create(sub { ... }, ...);
216 \& # or
217 \& my $thr = threads\->create(\e&func, ...);
218 .Ve
219 .Sp
220 The \f(CW\*(C`\->new()\*(C'\fR method is an alias for \f(CW\*(C`\->create()\*(C'\fR.
221 .ie n .IP $thr\->\fBjoin()\fR 4
222 .el .IP \f(CW$thr\fR\->\fBjoin()\fR 4
223 .IX Item "$thr->join()"
224 This will wait for the corresponding thread to complete its execution. When
225 the thread finishes, \f(CW\*(C`\->join()\*(C'\fR will return the return value(s) of the
226 entry point function.
227 .Sp
228 The context (void, scalar or list) for the return value(s) for \f(CW\*(C`\->join()\*(C'\fR
229 is determined at the time of thread creation.
230 .Sp
231 .Vb 10
232 \& # Create thread in list context (implicit)
233 \& my ($thr1) = threads\->create(sub {
234 \& my @results = qw(a b c);
235 \& return (@results);
236 \& });
237 \& # or (explicit)
238 \& my $thr1 = threads\->create({\*(Aqcontext\*(Aq => \*(Aqlist\*(Aq},
239 \& sub {
240 \& my @results = qw(a b c);
241 \& return (@results);
242 \& });
243 \& # Retrieve list results from thread
244 \& my @res1 = $thr1\->join();
245 \&
246 \& # Create thread in scalar context (implicit)
247 \& my $thr2 = threads\->create(sub {
248 \& my $result = 42;
249 \& return ($result);
250 \& });
251 \& # Retrieve scalar result from thread
252 \& my $res2 = $thr2\->join();
253 \&
254 \& # Create a thread in void context (explicit)
255 \& my $thr3 = threads\->create({\*(Aqvoid\*(Aq => 1},
256 \& sub { print("Hello, world\en"); });
257 \& # Join the thread in void context (i.e., no return value)
258 \& $thr3\->join();
259 .Ve
260 .Sp
261 See "THREAD CONTEXT" for more details.
262 .Sp
263 If the program exits without all threads having either been joined or
264 detached, then a warning will be issued.
265 .Sp
266 Calling \f(CW\*(C`\->join()\*(C'\fR or \f(CW\*(C`\->detach()\*(C'\fR on an already joined thread will
267 cause an error to be thrown.
268 .ie n .IP $thr\->\fBdetach()\fR 4
269 .el .IP \f(CW$thr\fR\->\fBdetach()\fR 4
270 .IX Item "$thr->detach()"
271 Makes the thread unjoinable, and causes any eventual return value to be
272 discarded. When the program exits, any detached threads that are still
273 running are silently terminated.
274 .Sp
275 If the program exits without all threads having either been joined or
276 detached, then a warning will be issued.
277 .Sp
278 Calling \f(CW\*(C`\->join()\*(C'\fR or \f(CW\*(C`\->detach()\*(C'\fR on an already detached thread
279 will cause an error to be thrown.
280 .IP threads\->\fBdetach()\fR 4
281 .IX Item "threads->detach()"
282 Class method that allows a thread to detach itself.
283 .IP threads\->\fBself()\fR 4
284 .IX Item "threads->self()"
285 Class method that allows a thread to obtain its own \fIthreads\fR object.
286 .ie n .IP $thr\->\fBtid()\fR 4
287 .el .IP \f(CW$thr\fR\->\fBtid()\fR 4
288 .IX Item "$thr->tid()"
289 Returns the ID of the thread. Thread IDs are unique integers with the main
290 thread in a program being 0, and incrementing by 1 for every thread created.
291 .IP threads\->\fBtid()\fR 4
292 .IX Item "threads->tid()"
293 Class method that allows a thread to obtain its own ID.
294 .IP """$thr""" 4
295 .IX Item """$thr"""
296 If you add the \f(CW\*(C`stringify\*(C'\fR import option to your \f(CW\*(C`use threads\*(C'\fR declaration,
297 then using a threads object in a string or a string context (e.g., as a hash
298 key) will cause its ID to be used as the value:
299 .Sp
300 .Vb 1
301 \& use threads qw(stringify);
302 \&
303 \& my $thr = threads\->create(...);
304 \& print("Thread $thr started\en"); # Prints: Thread 1 started
305 .Ve
306 .IP threads\->object($tid) 4
307 .IX Item "threads->object($tid)"
308 This will return the \fIthreads\fR object for the \fIactive\fR thread associated
309 with the specified thread ID. If \f(CW$tid\fR is the value for the current thread,
310 then this call works the same as \f(CW\*(C`\->self()\*(C'\fR. Otherwise, returns \f(CW\*(C`undef\*(C'\fR
311 if there is no thread associated with the TID, if the thread is joined or
312 detached, if no TID is specified or if the specified TID is undef.
313 .IP threads\->\fByield()\fR 4
314 .IX Item "threads->yield()"
315 This is a suggestion to the OS to let this thread yield CPU time to other
316 threads. What actually happens is highly dependent upon the underlying
317 thread implementation.
318 .Sp
319 You may do \f(CW\*(C`use threads qw(yield)\*(C'\fR, and then just use \f(CWyield()\fR in your
320 code.
321 .IP threads\->\fBlist()\fR 4
322 .IX Item "threads->list()"
323 .PD 0
324 .IP threads\->list(threads::all) 4
325 .IX Item "threads->list(threads::all)"
326 .IP threads\->list(threads::running) 4
327 .IX Item "threads->list(threads::running)"
328 .IP threads\->list(threads::joinable) 4
329 .IX Item "threads->list(threads::joinable)"
330 .PD
331 With no arguments (or using \f(CW\*(C`threads::all\*(C'\fR) and in a list context, returns a
332 list of all non\-joined, non\-detached \fIthreads\fR objects. In a scalar context,
333 returns a count of the same.
334 .Sp
335 With a \fItrue\fR argument (using \f(CW\*(C`threads::running\*(C'\fR), returns a list of all
336 non\-joined, non\-detached \fIthreads\fR objects that are still running.
337 .Sp
338 With a \fIfalse\fR argument (using \f(CW\*(C`threads::joinable\*(C'\fR), returns a list of all
339 non\-joined, non\-detached \fIthreads\fR objects that have finished running (i.e.,
340 for which \f(CW\*(C`\->join()\*(C'\fR will not \fIblock\fR).
341 .ie n .IP $thr1\->equal($thr2) 4
342 .el .IP \f(CW$thr1\fR\->equal($thr2) 4
343 .IX Item "$thr1->equal($thr2)"
344 Tests if two threads objects are the same thread or not. This is overloaded
345 to the more natural forms:
346 .Sp
347 .Vb 7
348 \& if ($thr1 == $thr2) {
349 \& print("Threads are the same\en");
350 \& }
351 \& # or
352 \& if ($thr1 != $thr2) {
353 \& print("Threads differ\en");
354 \& }
355 .Ve
356 .Sp
357 (Thread comparison is based on thread IDs.)
358 .IP "async BLOCK;" 4
359 .IX Item "async BLOCK;"
360 \&\f(CW\*(C`async\*(C'\fR creates a thread to execute the block immediately following
361 it. This block is treated as an anonymous subroutine, and so must have a
362 semicolon after the closing brace. Like \f(CW\*(C`threads\->create()\*(C'\fR, \f(CW\*(C`async\*(C'\fR
363 returns a \fIthreads\fR object.
364 .ie n .IP $thr\->\fBerror()\fR 4
365 .el .IP \f(CW$thr\fR\->\fBerror()\fR 4
366 .IX Item "$thr->error()"
367 Threads are executed in an \f(CW\*(C`eval\*(C'\fR context. This method will return \f(CW\*(C`undef\*(C'\fR
368 if the thread terminates \fInormally\fR. Otherwise, it returns the value of
369 \&\f(CW$@\fR associated with the thread\*(Aqs execution status in its \f(CW\*(C`eval\*(C'\fR context.
370 .ie n .IP $thr\->\fB_handle()\fR 4
371 .el .IP \f(CW$thr\fR\->\fB_handle()\fR 4
372 .IX Item "$thr->_handle()"
373 This \fIprivate\fR method returns a pointer (i.e., the memory location expressed
374 as an unsigned integer) to the internal thread structure associated with a
375 threads object. For Win32, this is a pointer to the \f(CW\*(C`HANDLE\*(C'\fR value returned
376 by \f(CW\*(C`CreateThread\*(C'\fR (i.e., \f(CW\*(C`HANDLE *\*(C'\fR); for other platforms, it is a pointer
377 to the \f(CW\*(C`pthread_t\*(C'\fR structure used in the \f(CW\*(C`pthread_create\*(C'\fR call (i.e.,
378 \&\f(CW\*(C`pthread_t *\*(C'\fR).
379 .Sp
380 This method is of no use for general Perl threads programming. Its intent is
381 to provide other (XS\-based) thread modules with the capability to access, and
382 possibly manipulate, the underlying thread structure associated with a Perl
383 thread.
384 .IP threads\->\fB_handle()\fR 4
385 .IX Item "threads->_handle()"
386 Class method that allows a thread to obtain its own \fIhandle\fR.
387 .SH "EXITING A THREAD"
388 .IX Header "EXITING A THREAD"
389 The usual method for terminating a thread is to
390 \&\fBreturn()\fR from the entry point function with the
391 appropriate return value(s).
392 .IP threads\->\fBexit()\fR 4
393 .IX Item "threads->exit()"
394 If needed, a thread can be exited at any time by calling
395 \&\f(CW\*(C`threads\->exit()\*(C'\fR. This will cause the thread to return \f(CW\*(C`undef\*(C'\fR in a
396 scalar context, or the empty list in a list context.
397 .Sp
398 When called from the \fImain\fR thread, this behaves the same as \f(CWexit(0)\fR.
399 .IP threads\->exit(status) 4
400 .IX Item "threads->exit(status)"
401 When called from a thread, this behaves like \f(CW\*(C`threads\->exit()\*(C'\fR (i.e., the
402 exit status code is ignored).
403 .Sp
404 When called from the \fImain\fR thread, this behaves the same as \f(CWexit(status)\fR.
405 .IP \fBdie()\fR 4
406 .IX Item "die()"
407 Calling \f(CWdie()\fR in a thread indicates an abnormal exit for the thread. Any
408 \&\f(CW$SIG{_\|_DIE_\|_}\fR handler in the thread will be called first, and then the
409 thread will exit with a warning message that will contain any arguments passed
410 in the \f(CWdie()\fR call.
411 .IP exit(status) 4
412 .IX Item "exit(status)"
413 Calling \fBexit()\fR inside a thread causes the whole
414 application to terminate. Because of this, the use of \f(CWexit()\fR inside
415 threaded code, or in modules that might be used in threaded applications, is
416 strongly discouraged.
417 .Sp
418 If \f(CWexit()\fR really is needed, then consider using the following:
419 .Sp
420 .Vb 2
421 \& threads\->exit() if threads\->can(\*(Aqexit\*(Aq); # Thread friendly
422 \& exit(status);
423 .Ve
424 .IP "use threads \*(Aqexit\*(Aq => \*(Aqthreads_only\*(Aq" 4
425 .IX Item "use threads 'exit' => 'threads_only'"
426 This globally overrides the default behavior of calling \f(CWexit()\fR inside a
427 thread, and effectively causes such calls to behave the same as
428 \&\f(CW\*(C`threads\->exit()\*(C'\fR. In other words, with this setting, calling \f(CWexit()\fR
429 causes only the thread to terminate.
430 .Sp
431 Because of its global effect, this setting should not be used inside modules
432 or the like.
433 .Sp
434 The \fImain\fR thread is unaffected by this setting.
435 .IP "threads\->create({\*(Aqexit\*(Aq => \*(Aqthread_only\*(Aq}, ...)" 4
436 .IX Item "threads->create({'exit' => 'thread_only'}, ...)"
437 This overrides the default behavior of \f(CWexit()\fR inside the newly created
438 thread only.
439 .ie n .IP $thr\->set_thread_exit_only(boolean) 4
440 .el .IP \f(CW$thr\fR\->set_thread_exit_only(boolean) 4
441 .IX Item "$thr->set_thread_exit_only(boolean)"
442 This can be used to change the \fIexit thread only\fR behavior for a thread after
443 it has been created. With a \fItrue\fR argument, \f(CWexit()\fR will cause only the
444 thread to exit. With a \fIfalse\fR argument, \f(CWexit()\fR will terminate the
445 application.
446 .Sp
447 The \fImain\fR thread is unaffected by this call.
448 .IP threads\->set_thread_exit_only(boolean) 4
449 .IX Item "threads->set_thread_exit_only(boolean)"
450 Class method for use inside a thread to change its own behavior for \f(CWexit()\fR.
451 .Sp
452 The \fImain\fR thread is unaffected by this call.
453 .SH "THREAD STATE"
454 .IX Header "THREAD STATE"
455 The following boolean methods are useful in determining the \fIstate\fR of a
456 thread.
457 .ie n .IP $thr\->\fBis_running()\fR 4
458 .el .IP \f(CW$thr\fR\->\fBis_running()\fR 4
459 .IX Item "$thr->is_running()"
460 Returns true if a thread is still running (i.e., if its entry point function
461 has not yet finished or exited).
462 .ie n .IP $thr\->\fBis_joinable()\fR 4
463 .el .IP \f(CW$thr\fR\->\fBis_joinable()\fR 4
464 .IX Item "$thr->is_joinable()"
465 Returns true if the thread has finished running, is not detached and has not
466 yet been joined. In other words, the thread is ready to be joined, and a call
467 to \f(CW\*(C`$thr\->join()\*(C'\fR will not \fIblock\fR.
468 .ie n .IP $thr\->\fBis_detached()\fR 4
469 .el .IP \f(CW$thr\fR\->\fBis_detached()\fR 4
470 .IX Item "$thr->is_detached()"
471 Returns true if the thread has been detached.
472 .IP threads\->\fBis_detached()\fR 4
473 .IX Item "threads->is_detached()"
474 Class method that allows a thread to determine whether or not it is detached.
475 .SH "THREAD CONTEXT"
476 .IX Header "THREAD CONTEXT"
477 As with subroutines, the type of value returned from a thread\*(Aqs entry point
478 function may be determined by the thread\*(Aqs \fIcontext\fR: list, scalar or void.
479 The thread\*(Aqs context is determined at thread creation. This is necessary so
480 that the context is available to the entry point function via
481 \&\fBwantarray()\fR. The thread may then specify a value of
482 the appropriate type to be returned from \f(CW\*(C`\->join()\*(C'\fR.
483 .SS "Explicit context"
484 .IX Subsection "Explicit context"
485 Because thread creation and thread joining may occur in different contexts, it
486 may be desirable to state the context explicitly to the thread\*(Aqs entry point
487 function. This may be done by calling \f(CW\*(C`\->create()\*(C'\fR with a hash reference
488 as the first argument:
489 .PP
490 .Vb 3
491 \& my $thr = threads\->create({\*(Aqcontext\*(Aq => \*(Aqlist\*(Aq}, \e&foo);
492 \& ...
493 \& my @results = $thr\->join();
494 .Ve
495 .PP
496 In the above, the threads object is returned to the parent thread in scalar
497 context, and the thread\*(Aqs entry point function \f(CW\*(C`foo\*(C'\fR will be called in list
498 (array) context such that the parent thread can receive a list (array) from
499 the \f(CW\*(C`\->join()\*(C'\fR call. (\f(CW\*(Aqarray\*(Aq\fR is synonymous with \f(CW\*(Aqlist\*(Aq\fR.)
500 .PP
501 Similarly, if you need the threads object, but your thread will not be
502 returning a value (i.e., \fIvoid\fR context), you would do the following:
503 .PP
504 .Vb 3
505 \& my $thr = threads\->create({\*(Aqcontext\*(Aq => \*(Aqvoid\*(Aq}, \e&foo);
506 \& ...
507 \& $thr\->join();
508 .Ve
509 .PP
510 The context type may also be used as the \fIkey\fR in the hash reference followed
511 by a \fItrue\fR value:
512 .PP
513 .Vb 4
514 \& threads\->create({\*(Aqscalar\*(Aq => 1}, \e&foo);
515 \& ...
516 \& my ($thr) = threads\->list();
517 \& my $result = $thr\->join();
518 .Ve
519 .SS "Implicit context"
520 .IX Subsection "Implicit context"
521 If not explicitly stated, the thread\*(Aqs context is implied from the context
522 of the \f(CW\*(C`\->create()\*(C'\fR call:
523 .PP
524 .Vb 2
525 \& # Create thread in list context
526 \& my ($thr) = threads\->create(...);
527 \&
528 \& # Create thread in scalar context
529 \& my $thr = threads\->create(...);
530 \&
531 \& # Create thread in void context
532 \& threads\->create(...);
533 .Ve
534 .ie n .SS $thr\->\fBwantarray()\fP
535 .el .SS \f(CW$thr\fP\->\fBwantarray()\fP
536 .IX Subsection "$thr->wantarray()"
537 This returns the thread\*(Aqs context in the same manner as
538 \&\fBwantarray()\fR.
539 .SS threads\->\fBwantarray()\fP
540 .IX Subsection "threads->wantarray()"
541 Class method to return the current thread\*(Aqs context. This returns the same
542 value as running \fBwantarray()\fR inside the current
543 thread\*(Aqs entry point function.
544 .SH "THREAD STACK SIZE"
545 .IX Header "THREAD STACK SIZE"
546 The default per\-thread stack size for different platforms varies
547 significantly, and is almost always far more than is needed for most
548 applications. On Win32, Perl\*(Aqs makefile explicitly sets the default stack to
549 16 MB; on most other platforms, the system default is used, which again may be
550 much larger than is needed.
551 .PP
552 By tuning the stack size to more accurately reflect your application\*(Aqs needs,
553 you may significantly reduce your application\*(Aqs memory usage, and increase the
554 number of simultaneously running threads.
555 .PP
556 Note that on Windows, address space allocation granularity is 64 KB,
557 therefore, setting the stack smaller than that on Win32 Perl will not save any
558 more memory.
559 .IP threads\->\fBget_stack_size()\fR; 4
560 .IX Item "threads->get_stack_size();"
561 Returns the current default per\-thread stack size. The default is zero, which
562 means the system default stack size is currently in use.
563 .ie n .IP "$size = $thr\->\fBget_stack_size()\fR;" 4
564 .el .IP "\f(CW$size\fR = \f(CW$thr\fR\->\fBget_stack_size()\fR;" 4
565 .IX Item "$size = $thr->get_stack_size();"
566 Returns the stack size for a particular thread. A return value of zero
567 indicates the system default stack size was used for the thread.
568 .ie n .IP "$old_size = threads\->set_stack_size($new_size);" 4
569 .el .IP "\f(CW$old_size\fR = threads\->set_stack_size($new_size);" 4
570 .IX Item "$old_size = threads->set_stack_size($new_size);"
571 Sets a new default per\-thread stack size, and returns the previous setting.
572 .Sp
573 Some platforms have a minimum thread stack size. Trying to set the stack size
574 below this value will result in a warning, and the minimum stack size will be
575 used.
576 .Sp
577 Some Linux platforms have a maximum stack size. Setting too large of a stack
578 size will cause thread creation to fail.
579 .Sp
580 If needed, \f(CW$new_size\fR will be rounded up to the next multiple of the memory
581 page size (usually 4096 or 8192).
582 .Sp
583 Threads created after the stack size is set will then either call
584 \&\f(CWpthread_attr_setstacksize()\fR \fI(for pthreads platforms)\fR, or supply the
585 stack size to \f(CWCreateThread()\fR \fI(for Win32 Perl)\fR.
586 .Sp
587 (Obviously, this call does not affect any currently extant threads.)
588 .IP "use threads (\*(Aqstack_size\*(Aq => VALUE);" 4
589 .IX Item "use threads ('stack_size' => VALUE);"
590 This sets the default per\-thread stack size at the start of the application.
591 .ie n .IP $ENV{\*(AqPERL5_ITHREADS_STACK_SIZE\*(Aq} 4
592 .el .IP \f(CW$ENV\fR{\*(AqPERL5_ITHREADS_STACK_SIZE\*(Aq} 4
593 .IX Item "$ENV{'PERL5_ITHREADS_STACK_SIZE'}"
594 The default per\-thread stack size may be set at the start of the application
595 through the use of the environment variable \f(CW\*(C`PERL5_ITHREADS_STACK_SIZE\*(C'\fR:
596 .Sp
597 .Vb 3
598 \& PERL5_ITHREADS_STACK_SIZE=1048576
599 \& export PERL5_ITHREADS_STACK_SIZE
600 \& perl \-e\*(Aquse threads; print(threads\->get_stack_size(), "\en")\*(Aq
601 .Ve
602 .Sp
603 This value overrides any \f(CW\*(C`stack_size\*(C'\fR parameter given to \f(CW\*(C`use threads\*(C'\fR. Its
604 primary purpose is to permit setting the per\-thread stack size for legacy
605 threaded applications.
606 .IP "threads\->create({\*(Aqstack_size\*(Aq => VALUE}, FUNCTION, ARGS)" 4
607 .IX Item "threads->create({'stack_size' => VALUE}, FUNCTION, ARGS)"
608 To specify a particular stack size for any individual thread, call
609 \&\f(CW\*(C`\->create()\*(C'\fR with a hash reference as the first argument:
610 .Sp
611 .Vb 2
612 \& my $thr = threads\->create({\*(Aqstack_size\*(Aq => 32*4096},
613 \& \e&foo, @args);
614 .Ve
615 .ie n .IP "$thr2 = $thr1\->create(FUNCTION, ARGS)" 4
616 .el .IP "\f(CW$thr2\fR = \f(CW$thr1\fR\->create(FUNCTION, ARGS)" 4
617 .IX Item "$thr2 = $thr1->create(FUNCTION, ARGS)"
618 This creates a new thread (\f(CW$thr2\fR) that inherits the stack size from an
619 existing thread (\f(CW$thr1\fR). This is shorthand for the following:
620 .Sp
621 .Vb 3
622 \& my $stack_size = $thr1\->get_stack_size();
623 \& my $thr2 = threads\->create({\*(Aqstack_size\*(Aq => $stack_size},
624 \& FUNCTION, ARGS);
625 .Ve
626 .SH "THREAD SIGNALLING"
627 .IX Header "THREAD SIGNALLING"
628 When safe signals is in effect (the default behavior \- see "Unsafe signals"
629 for more details), then signals may be sent and acted upon by individual
630 threads.
631 .ie n .IP $thr\->kill(\*(AqSIG...\*(Aq); 4
632 .el .IP \f(CW$thr\fR\->kill(\*(AqSIG...\*(Aq); 4
633 .IX Item "$thr->kill('SIG...');"
634 Sends the specified signal to the thread. Signal names and (positive) signal
635 numbers are the same as those supported by
636 \&\fBkill()\fR. For example, \*(AqSIGTERM\*(Aq, \*(AqTERM\*(Aq and
637 (depending on the OS) 15 are all valid arguments to \f(CW\*(C`\->kill()\*(C'\fR.
638 .Sp
639 Returns the thread object to allow for method chaining:
640 .Sp
641 .Vb 1
642 \& $thr\->kill(\*(AqSIG...\*(Aq)\->join();
643 .Ve
644 .PP
645 Signal handlers need to be set up in the threads for the signals they are
646 expected to act upon. Here\*(Aqs an example for \fIcancelling\fR a thread:
647 .PP
648 .Vb 1
649 \& use threads;
650 \&
651 \& sub thr_func
652 \& {
653 \& # Thread \*(Aqcancellation\*(Aq signal handler
654 \& $SIG{\*(AqKILL\*(Aq} = sub { threads\->exit(); };
655 \&
656 \& ...
657 \& }
658 \&
659 \& # Create a thread
660 \& my $thr = threads\->create(\*(Aqthr_func\*(Aq);
661 \&
662 \& ...
663 \&
664 \& # Signal the thread to terminate, and then detach
665 \& # it so that it will get cleaned up automatically
666 \& $thr\->kill(\*(AqKILL\*(Aq)\->detach();
667 .Ve
668 .PP
669 Here\*(Aqs another simplistic example that illustrates the use of thread
670 signalling in conjunction with a semaphore to provide rudimentary \fIsuspend\fR
671 and \fIresume\fR capabilities:
672 .PP
673 .Vb 2
674 \& use threads;
675 \& use Thread::Semaphore;
676 \&
677 \& sub thr_func
678 \& {
679 \& my $sema = shift;
680 \&
681 \& # Thread \*(Aqsuspend/resume\*(Aq signal handler
682 \& $SIG{\*(AqSTOP\*(Aq} = sub {
683 \& $sema\->down(); # Thread suspended
684 \& $sema\->up(); # Thread resumes
685 \& };
686 \&
687 \& ...
688 \& }
689 \&
690 \& # Create a semaphore and pass it to a thread
691 \& my $sema = Thread::Semaphore\->new();
692 \& my $thr = threads\->create(\*(Aqthr_func\*(Aq, $sema);
693 \&
694 \& # Suspend the thread
695 \& $sema\->down();
696 \& $thr\->kill(\*(AqSTOP\*(Aq);
697 \&
698 \& ...
699 \&
700 \& # Allow the thread to continue
701 \& $sema\->up();
702 .Ve
703 .PP
704 CAVEAT: The thread signalling capability provided by this module does not
705 actually send signals via the OS. It \fIemulates\fR signals at the Perl\-level
706 such that signal handlers are called in the appropriate thread. For example,
707 sending \f(CW\*(C`$thr\->kill(\*(AqSTOP\*(Aq)\*(C'\fR does not actually suspend a thread (or the
708 whole process), but does cause a \f(CW$SIG{\*(AqSTOP\*(Aq}\fR handler to be called in that
709 thread (as illustrated above).
710 .PP
711 As such, signals that would normally not be appropriate to use in the
712 \&\f(CWkill()\fR command (e.g., \f(CW\*(C`kill(\*(AqKILL\*(Aq, $$)\*(C'\fR) are okay to use with the
713 \&\f(CW\*(C`\->kill()\*(C'\fR method (again, as illustrated above).
714 .PP
715 Correspondingly, sending a signal to a thread does not disrupt the operation
716 the thread is currently working on: The signal will be acted upon after the
717 current operation has completed. For instance, if the thread is \fIstuck\fR on
718 an I/O call, sending it a signal will not cause the I/O call to be interrupted
719 such that the signal is acted up immediately.
720 .PP
721 Sending a signal to a terminated/finished thread is ignored.
722 .SH WARNINGS
723 .IX Header "WARNINGS"
724 .IP "Perl exited with active threads:" 4
725 .IX Item "Perl exited with active threads:"
726 If the program exits without all threads having either been joined or
727 detached, then this warning will be issued.
728 .Sp
729 NOTE: If the \fImain\fR thread exits, then this warning cannot be suppressed
730 using \f(CW\*(C`no warnings \*(Aqthreads\*(Aq;\*(C'\fR as suggested below.
731 .IP "Thread creation failed: pthread_create returned #" 4
732 .IX Item "Thread creation failed: pthread_create returned #"
733 See the appropriate \fIman\fR page for \f(CW\*(C`pthread_create\*(C'\fR to determine the actual
734 cause for the failure.
735 .IP "Thread # terminated abnormally: ..." 4
736 .IX Item "Thread # terminated abnormally: ..."
737 A thread terminated in some manner other than just returning from its entry
738 point function, or by using \f(CW\*(C`threads\->exit()\*(C'\fR. For example, the thread
739 may have terminated because of an error, or by using \f(CW\*(C`die\*(C'\fR.
740 .IP "Using minimum thread stack size of #" 4
741 .IX Item "Using minimum thread stack size of #"
742 Some platforms have a minimum thread stack size. Trying to set the stack size
743 below this value will result in the above warning, and the stack size will be
744 set to the minimum.
745 .IP "Thread creation failed: pthread_attr_setstacksize(\fISIZE\fR) returned 22" 4
746 .IX Item "Thread creation failed: pthread_attr_setstacksize(SIZE) returned 22"
747 The specified \fISIZE\fR exceeds the system\*(Aqs maximum stack size. Use a smaller
748 value for the stack size.
749 .PP
750 If needed, thread warnings can be suppressed by using:
751 .PP
752 .Vb 1
753 \& no warnings \*(Aqthreads\*(Aq;
754 .Ve
755 .PP
756 in the appropriate scope.
757 .SH ERRORS
758 .IX Header "ERRORS"
759 .IP "This Perl not built to support threads" 4
760 .IX Item "This Perl not built to support threads"
761 The particular copy of Perl that you\*(Aqre trying to use was not built using the
762 \&\f(CW\*(C`useithreads\*(C'\fR configuration option.
763 .Sp
764 Having threads support requires all of Perl and all of the XS modules in the
765 Perl installation to be rebuilt; it is not just a question of adding the
766 threads module (i.e., threaded and non\-threaded Perls are binary
767 incompatible).
768 .IP "Cannot change stack size of an existing thread" 4
769 .IX Item "Cannot change stack size of an existing thread"
770 The stack size of currently extant threads cannot be changed, therefore, the
771 following results in the above error:
772 .Sp
773 .Vb 1
774 \& $thr\->set_stack_size($size);
775 .Ve
776 .IP "Cannot signal threads without safe signals" 4
777 .IX Item "Cannot signal threads without safe signals"
778 Safe signals must be in effect to use the \f(CW\*(C`\->kill()\*(C'\fR signalling method.
779 See "Unsafe signals" for more details.
780 .IP "Unrecognized signal name: ..." 4
781 .IX Item "Unrecognized signal name: ..."
782 The particular copy of Perl that you\*(Aqre trying to use does not support the
783 specified signal being used in a \f(CW\*(C`\->kill()\*(C'\fR call.
784 .SH "BUGS AND LIMITATIONS"
785 .IX Header "BUGS AND LIMITATIONS"
786 Before you consider posting a bug report, please consult, and possibly post a
787 message to the discussion forum to see if what you\*(Aqve encountered is a known
788 problem.
789 .IP "Thread\-safe modules" 4
790 .IX Item "Thread-safe modules"
791 See "Making your module threadsafe" in perlmod when creating modules that may
792 be used in threaded applications, especially if those modules use non\-Perl
793 data, or XS code.
794 .IP "Using non\-thread\-safe modules" 4
795 .IX Item "Using non-thread-safe modules"
796 Unfortunately, you may encounter Perl modules that are not \fIthread\-safe\fR.
797 For example, they may crash the Perl interpreter during execution, or may dump
798 core on termination. Depending on the module and the requirements of your
799 application, it may be possible to work around such difficulties.
800 .Sp
801 If the module will only be used inside a thread, you can try loading the
802 module from inside the thread entry point function using \f(CW\*(C`require\*(C'\fR (and
803 \&\f(CW\*(C`import\*(C'\fR if needed):
804 .Sp
805 .Vb 4
806 \& sub thr_func
807 \& {
808 \& require Unsafe::Module
809 \& # Unsafe::Module\->import(...);
810 \&
811 \& ....
812 \& }
813 .Ve
814 .Sp
815 If the module is needed inside the \fImain\fR thread, try modifying your
816 application so that the module is loaded (again using \f(CW\*(C`require\*(C'\fR and
817 \&\f(CW\*(C`\->import()\*(C'\fR) after any threads are started, and in such a way that no
818 other threads are started afterwards.
819 .Sp
820 If the above does not work, or is not adequate for your application, then file
821 a bug report on <https://rt.cpan.org/Public/> against the problematic module.
822 .IP "Memory consumption" 4
823 .IX Item "Memory consumption"
824 On most systems, frequent and continual creation and destruction of threads
825 can lead to ever\-increasing growth in the memory footprint of the Perl
826 interpreter. While it is simple to just launch threads and then
827 \&\f(CW\*(C`\->join()\*(C'\fR or \f(CW\*(C`\->detach()\*(C'\fR them, for long\-lived applications, it is
828 better to maintain a pool of threads, and to reuse them for the work needed,
829 using queues to notify threads of pending work. The CPAN
830 distribution of this module contains a simple example
831 (\fIexamples/pool_reuse.pl\fR) illustrating the creation, use and monitoring of a
832 pool of \fIreusable\fR threads.
833 .IP "Current working directory" 4
834 .IX Item "Current working directory"
835 On all platforms except MSWin32, the setting for the current working directory
836 is shared among all threads such that changing it in one thread (e.g., using
837 \&\f(CWchdir()\fR) will affect all the threads in the application.
838 .Sp
839 On MSWin32, each thread maintains its own the current working directory
840 setting.
841 .IP Locales 4
842 .IX Item "Locales"
843 Prior to Perl 5.28, locales could not be used with threads, due to various
844 race conditions. Starting in that release, on systems that implement
845 thread\-safe locale functions, threads can be used, with some caveats.
846 This includes Windows starting with Visual Studio 2005, and systems compatible
847 with POSIX 2008. See "Multi\-threaded operation" in perllocale.
848 .Sp
849 Each thread (except the main thread) is started using the C locale. The main
850 thread is started like all other Perl programs; see "ENVIRONMENT" in perllocale.
851 You can switch locales in any thread as often as you like.
852 .Sp
853 If you want to inherit the parent thread\*(Aqs locale, you can, in the parent, set
854 a variable like so:
855 .Sp
856 .Vb 1
857 \& $foo = POSIX::setlocale(LC_ALL, NULL);
858 .Ve
859 .Sp
860 and then pass to threads\->\fBcreate()\fR a sub that closes over \f(CW$foo\fR. Then, in
861 the child, you say
862 .Sp
863 .Vb 1
864 \& POSIX::setlocale(LC_ALL, $foo);
865 .Ve
866 .Sp
867 Or you can use the facilities in threads::shared to pass \f(CW$foo\fR;
868 or if the environment hasn\*(Aqt changed, in the child, do
869 .Sp
870 .Vb 1
871 \& POSIX::setlocale(LC_ALL, "");
872 .Ve
873 .IP "Environment variables" 4
874 .IX Item "Environment variables"
875 Currently, on all platforms except MSWin32, all \fIsystem\fR calls (e.g., using
876 \&\f(CWsystem()\fR or back\-ticks) made from threads use the environment variable
877 settings from the \fImain\fR thread. In other words, changes made to \f(CW%ENV\fR in
878 a thread will not be visible in \fIsystem\fR calls made by that thread.
879 .Sp
880 To work around this, set environment variables as part of the \fIsystem\fR call.
881 For example:
882 .Sp
883 .Vb 2
884 \& my $msg = \*(Aqhello\*(Aq;
885 \& system("FOO=$msg; echo \e$FOO"); # Outputs \*(Aqhello\*(Aq to STDOUT
886 .Ve
887 .Sp
888 On MSWin32, each thread maintains its own set of environment variables.
889 .IP "Catching signals" 4
890 .IX Item "Catching signals"
891 Signals are \fIcaught\fR by the main thread (thread ID = 0) of a script.
892 Therefore, setting up signal handlers in threads for purposes other than
893 "THREAD SIGNALLING" as documented above will not accomplish what is
894 intended.
895 .Sp
896 This is especially true if trying to catch \f(CW\*(C`SIGALRM\*(C'\fR in a thread. To handle
897 alarms in threads, set up a signal handler in the main thread, and then use
898 "THREAD SIGNALLING" to relay the signal to the thread:
899 .Sp
900 .Vb 10
901 \& # Create thread with a task that may time out
902 \& my $thr = threads\->create(sub {
903 \& threads\->yield();
904 \& eval {
905 \& $SIG{ALRM} = sub { die("Timeout\en"); };
906 \& alarm(10);
907 \& ... # Do work here
908 \& alarm(0);
909 \& };
910 \& if ($@ =~ /Timeout/) {
911 \& warn("Task in thread timed out\en");
912 \& }
913 \& };
914 \&
915 \& # Set signal handler to relay SIGALRM to thread
916 \& $SIG{ALRM} = sub { $thr\->kill(\*(AqALRM\*(Aq) };
917 \&
918 \& ... # Main thread continues working
919 .Ve
920 .IP "Parent\-child threads" 4
921 .IX Item "Parent-child threads"
922 On some platforms, it might not be possible to destroy \fIparent\fR threads while
923 there are still existing \fIchild\fR threads.
924 .IP "Unsafe signals" 4
925 .IX Item "Unsafe signals"
926 Since Perl 5.8.0, signals have been made safer in Perl by postponing their
927 handling until the interpreter is in a \fIsafe\fR state. See
928 "Safe Signals" in perl58delta and "Deferred Signals (Safe Signals)" in perlipc
929 for more details.
930 .Sp
931 Safe signals is the default behavior, and the old, immediate, unsafe
932 signalling behavior is only in effect in the following situations:
933 .RS 4
934 .IP \(bu 4
935 Perl has been built with \f(CW\*(C`PERL_OLD_SIGNALS\*(C'\fR (see \f(CW\*(C`perl\ \-V\*(C'\fR).
936 .IP \(bu 4
937 The environment variable \f(CW\*(C`PERL_SIGNALS\*(C'\fR is set to \f(CW\*(C`unsafe\*(C'\fR
938 (see "PERL_SIGNALS" in perlrun).
939 .IP \(bu 4
940 The module Perl::Unsafe::Signals is used.
941 .RE
942 .RS 4
943 .Sp
944 If unsafe signals is in effect, then signal handling is not thread\-safe, and
945 the \f(CW\*(C`\->kill()\*(C'\fR signalling method cannot be used.
946 .RE
947 .IP "Identity of objects returned from threads" 4
948 .IX Item "Identity of objects returned from threads"
949 When a value is returned from a thread through a \f(CW\*(C`join\*(C'\fR operation,
950 the value and everything that it references is copied across to the
951 joining thread, in much the same way that values are copied upon thread
952 creation. This works fine for most kinds of value, including arrays,
953 hashes, and subroutines. The copying recurses through array elements,
954 reference scalars, variables closed over by subroutines, and other kinds
955 of reference.
956 .Sp
957 However, everything referenced by the returned value is a fresh copy in
958 the joining thread, even if a returned object had in the child thread
959 been a copy of something that previously existed in the parent thread.
960 After joining, the parent will therefore have a duplicate of each such
961 object. This sometimes matters, especially if the object gets mutated;
962 this can especially matter for private data to which a returned subroutine
963 provides access.
964 .IP "Returning blessed objects from threads" 4
965 .IX Item "Returning blessed objects from threads"
966 Returning blessed objects from threads does not work. Depending on the classes
967 involved, you may be able to work around this by returning a serialized
968 version of the object (e.g., using Data::Dumper or Storable), and then
969 reconstituting it in the joining thread. If you\*(Aqre using Perl 5.10.0 or
970 later, and if the class supports shared objects,
971 you can pass them via shared queues.
972 .IP "END blocks in threads" 4
973 .IX Item "END blocks in threads"
974 It is possible to add END blocks to threads by using require or
975 eval with the appropriate code. These \f(CW\*(C`END\*(C'\fR blocks
976 will then be executed when the thread\*(Aqs interpreter is destroyed (i.e., either
977 during a \f(CW\*(C`\->join()\*(C'\fR call, or at program termination).
978 .Sp
979 However, calling any threads methods in such an \f(CW\*(C`END\*(C'\fR block will most
980 likely \fIfail\fR (e.g., the application may hang, or generate an error) due to
981 mutexes that are needed to control functionality within the threads module.
982 .Sp
983 For this reason, the use of \f(CW\*(C`END\*(C'\fR blocks in threads is \fBstrongly\fR
984 discouraged.
985 .IP "Open directory handles" 4
986 .IX Item "Open directory handles"
987 In perl 5.14 and higher, on systems other than Windows that do
988 not support the \f(CW\*(C`fchdir\*(C'\fR C function, directory handles (see
989 opendir) will not be copied to new
990 threads. You can use the \f(CW\*(C`d_fchdir\*(C'\fR variable in Config.pm to
991 determine whether your system supports it.
992 .Sp
993 In prior perl versions, spawning threads with open directory handles would
994 crash the interpreter.
995 [perl #75154] <https://rt.perl.org/rt3/Public/Bug/Display.html?id=75154>
996 .IP "Detached threads and global destruction" 4
997 .IX Item "Detached threads and global destruction"
998 If the main thread exits while there are detached threads which are still
999 running, then Perl\*(Aqs global destruction phase is not executed because
1000 otherwise certain global structures that control the operation of threads and
1001 that are allocated in the main thread\*(Aqs memory may get destroyed before the
1002 detached thread is destroyed.
1003 .Sp
1004 If you are using any code that requires the execution of the global
1005 destruction phase for clean up (e.g., removing temp files), then do not use
1006 detached threads, but rather join all threads before exiting the program.
1007 .IP "Perl Bugs and the CPAN Version of threads" 4
1008 .IX Item "Perl Bugs and the CPAN Version of threads"
1009 Support for threads extends beyond the code in this module (i.e.,
1010 \&\fIthreads.pm\fR and \fIthreads.xs\fR), and into the Perl interpreter itself. Older
1011 versions of Perl contain bugs that may manifest themselves despite using the
1012 latest version of threads from CPAN. There is no workaround for this other
1013 than upgrading to the latest version of Perl.
1014 .Sp
1015 Even with the latest version of Perl, it is known that certain constructs
1016 with threads may result in warning messages concerning leaked scalars or
1017 unreferenced scalars. However, such warnings are harmless, and may safely be
1018 ignored.
1019 .Sp
1020 You can search for threads related bug reports at
1021 <https://rt.cpan.org/Public/>. If needed submit any new bugs, problems,
1022 patches, etc. to: <https://rt.cpan.org/Public/Dist/Display.html?Name=threads>
1023 .SH REQUIREMENTS
1024 .IX Header "REQUIREMENTS"
1025 Perl 5.8.0 or later
1026 .SH "SEE ALSO"
1027 .IX Header "SEE ALSO"
1028 threads on MetaCPAN:
1029 <https://metacpan.org/release/threads>
1030 .PP
1031 Code repository for CPAN distribution:
1032 <https://github.com/Dual\-Life/threads>
1033 .PP
1034 threads::shared, perlthrtut
1035 .PP
1036 <https://www.perl.com/pub/a/2002/06/11/threads.html> and
1037 <https://www.perl.com/pub/a/2002/09/04/threads.html>
1038 .PP
1039 Perl threads mailing list:
1040 <https://lists.perl.org/list/ithreads.html>
1041 .PP
1042 Stack size discussion:
1043 <https://www.perlmonks.org/?node_id=532956>
1044 .PP
1045 Sample code in the \fIexamples\fR directory of this distribution on CPAN.
1046 .SH AUTHOR
1047 .IX Header "AUTHOR"
1048 Artur Bergman <sky AT crucially DOT net>
1049 .PP
1050 CPAN version produced by Jerry D. Hedden <jdhedden AT cpan DOT org>
1051 .SH LICENSE
1052 .IX Header "LICENSE"
1053 threads is released under the same license as Perl.
1054 .SH ACKNOWLEDGEMENTS
1055 .IX Header "ACKNOWLEDGEMENTS"
1056 Richard Soderberg <perl AT crystalflame DOT net> \-
1057 Helping me out tons, trying to find reasons for races and other weird bugs!
1058 .PP
1059 Simon Cozens <simon AT brecon DOT co DOT uk> \-
1060 Being there to answer zillions of annoying questions
1061 .PP
1062 Rocco Caputo <troc AT netrus DOT net>
1063 .PP
1064 Vipul Ved Prakash <mail AT vipul DOT net> \-
1065 Helping with debugging
1066 .PP
1067 Dean Arnold <darnold AT presicient DOT com> \-
1068 Stack size API