clean up the documentation of threads (#21067)

* clean up the documentation of threads

* cleanup
This commit is contained in:
ringabout 2022-12-10 23:23:31 +08:00 • committed by GitHub
commit 7a18c1ef44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 18 deletions

View file

@ -8424,23 +8424,12 @@ This is only useful if the program is compiled as a dynamic library via the
`--app:lib`:option: command-line option.
Threads
=======
To enable thread support the `--threads:on`:option: command-line switch needs to
be used. The [system module](system.html) module then contains several threading primitives.
See the [channels](channels_builtin.html) modules
for the low-level thread API. There are also high-level parallelism constructs
available. See [spawn](manual_experimental.html#parallel-amp-spawn) for
The `--threads:on`:option: command-line switch is enabled by default. The [typedthreads module](typedthreads.html) module then contains several threading primitives. See [spawn](manual_experimental.html#parallel-amp-spawn) for
further details.
Nim's memory model for threads is quite different than that of other common
programming languages (C, Pascal, Java): Each thread has its own (garbage
collected) heap, and sharing of memory is restricted to global variables. This
helps to prevent race conditions. GC efficiency is improved quite a lot,
because the GC never has to stop other threads and see what they reference.
The only way to create a thread is via `spawn` or
`createThread`. The invoked proc must not use `var` parameters nor must
any of its parameters contain a `ref` or `closure` type. This enforces