Thread

  • Properties of a thread (different from process)
    • Does not have its own memory space (stack still needs to be preallocated, which takes virtual memory but not physical memory until stack traces are needed.)
    • One process can create multiple threads
    • Potentially more efficient than process — does not require context switching
    • Inflexible — schedule may switch to a thread even when it’s still waiting.
    • Multi-threaded programs are extremely difficulty to design.

QUOTE

Second, and more important, we did not (and still do not) believe in the standard multithreading model, which is preemptive concurrency with shared memory: we still think that no one can write correct programs in a language where “a = a + 1” is not deterministic. — Roberto Ierusalimschy et al., “The Evolution of Lua”

  • Implementation of Thread
    • Can be implemented either in User Space or in Kernel Space, depending on where the thread table is hosted.
    • User-Level Thread: JVM
    • Kernel-Level Thread: POSIX Thread (pthread)