Thread concepts

  • OS threads vs Haskell threads
  • Bound threads
  • Enabling use of multiple OS threads

Every operating system has some kind of system for threads, concurrent flows of execution within one process. The same scheduler that the OS uses to allocate CPU time among processes is also used to schedule the interleaved execution of threads.

Haskell chooses to implement its own multithreading abstraction instead of simply using native OS threads directly, because OS threads are slower to initialize and have a greater memory cost. Threads in this kind of system, scheduled at the user level instead of by the OS, are sometimes called green threads. The term ‘green threads’ seems to have origins in the Sun Microsystems “Green Project” which created Java. Early versions of the Java virtual machine used green threads, though Java now uses native threads instead.

Sign up for access to the full page, plus the complete archive and all the latest content.