Skip to content

Commit 2637437

Browse files
tweaks
1 parent b401206 commit 2637437

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

base/threadingconstructs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ For example, the above conditions imply that:
233233
- Communicating between iterations using blocking primitives like `Channel`s is incorrect.
234234
- Write only to locations not shared across iterations (unless a lock or atomic operation is
235235
used).
236-
- The value of [`threadid()`](@ref Threads.threadid) may change even within a single
237-
iteration. See [`Task Migration`](@ref man-task-migration)
236+
- Unless the `:static` schedule is used, the value of [`threadid()`](@ref Threads.threadid)
237+
may change even within a single iteration. See [`Task Migration`](@ref man-task-migration).
238238
239239
## Schedulers
240240

doc/src/manual/multi-threading.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,13 @@ threads in Julia:
454454

455455
## [Task Migration](@id man-task-migration)
456456

457-
After a task starts running on a certain thread (e.g. via [`@spawn`](@ref Threads.@spawn) or
458-
[`@threads`](@ref Threads.@threads)), it may move to a different thread if the task yields.
457+
After a task starts running on a certain thread it may move to a different thread if the task yields.
459458

460-
This means that [`threadid()`](@ref Threads.threadid) should not be treated as constant within a task, and therefore
461-
should not be used to index into a vector of buffers or stateful objects.
459+
Such tasks may have been started with [`@spawn`](@ref Threads.@spawn) or [`@threads`](@ref Threads.@threads),
460+
although the `:static` schedule option for `@threads` does freeze the threadid.
461+
462+
This means that in most cases [`threadid()`](@ref Threads.threadid) should not be treated as constant within a task,
463+
and therefore should not be used to index into a vector of buffers or stateful objects.
462464

463465
!!! compat "Julia 1.7"
464466
Task migration was introduced in Julia 1.7. Before this tasks always remained on the same thread that they were

0 commit comments

Comments
 (0)