@@ -414,18 +414,22 @@ on the computer look something like this::
414
414
Hosts and processes are isolated and independent from one another.
415
415
However, threads are not.
416
416
417
- While a program always starts with exactly one thread, known as the
418
- "main" thread, it may grow to run in multiple. Not all platforms
419
- support threads, but most do. For those that do, each thread does *run *
420
- independently, for the small segments of time it is scheduled to execute
421
- its code on the CPU. Otherwise, all threads in a process share all the
422
- process' resources, including memory.
417
+ A program always starts with exactly one thread, known as the "main"
418
+ thread, it may grow to run in multiple. Not all platforms support
419
+ threads, but most do. For those that do, all threads in a process
420
+ share all the process' resources, including memory.
421
+
422
+ Each thread does *run * independently, at the same time as the others.
423
+ That may be only conceptually at the same time ("concurrently") or
424
+ physically ("in parallel"). Either way, the threads run at a
425
+ non-synchronized rate, which means global state isn't guaranteed
426
+ to stay consistent for any given thread.
423
427
424
428
.. note ::
425
429
426
430
The way they share resources is exactly what can make threads a pain:
427
- two threads running at the same arbitrary time on different CPU cores
428
- can accidentally interfere with each other's use of some shared data.
431
+ two threads running at the same time can accidentally interfere with
432
+ each other's use of some shared data.
429
433
430
434
The same layers apply to each Python program, with some extra layers
431
435
specific to Python::
0 commit comments