Many of the following words are the same as in the traditional
cooperative multi-tasker. However, while in the cooperative
multi-tasker you can be sure that any sequence of words between two
task-switching words (e.g., pause, ms, maybe I/O words)
is atomic, POSIX threads can switch tasks everywhere (pre-emptive
multitasking) or (worse) run two tasks at the same time on different
cores, often with unintuitive memory ordering by the hardware.
So, with pthreads, you need to use various ways to perform atomic accesses or use some mutual exclusion mechanism when dealing with written-to memory shared between tasks. Alternatively, you can use message queues, which avoid the need to deal with shared memory.