You are currently viewing a snapshot of taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to, please file a bug.

Threading on Unix

Author: Alec Flett <>
Thanks to Wan-Teh Chang for much of this information

This document should clarify general confusion about different threading APIs/implementation in Mozilla and 3rd party libraries like glib/gtk.


Native threads
A thread implementation that is supported by a unix kernel. For example, Linux's native threads are created with the clone() system call without the COPYVM flag set.
Threading Library
A user-space library and API that provides user-level access to native or user level threads. For example, pthreads (also known as Posix Threads) is the most popular threading library. Some Unix flavors (Solaris and UnixWare) also have an older API to their native threads. This API is called Unix International (UI) threads, and uses the thr_ prefix.

Operating System Specifics


  • The UI threads API is commonly referred to as Solaris threads.
  • The Solaris (thr_) threadsAPI and pthreads API are just two different APIs to the same underlying native thread implementation, so they are fully compatible.


  • You can't mix NSPR's user-level threads with the native pthreads. These two thread implementations are not compatible. You have to use the pthreads version of NSPR.

Threading Combinations

Mozilla, glib, and NSPR all do their own thread wrangling, so they must use compatible ways of interacting with threads. There are only a few ways of building all the libraries so that they are compatible:

  • pthreads
    1. glib: configure --with-threads=posix
    2. nspr: gmake MOZILLA_CLIENT=1 USE_PTHREADS=1
    3. mozilla: configure --with-pthreads
  • NSPR user-level threads
    1. glib: configure --with-threads=none
    2. nspr: gmake MOZILLA_CLIENT=1 (MOZILLA_CLIENT=1 makes user-level threads the default)
    3. mozilla: configure (default is to use user-level threads)