[ACCEPTED]-Heavy weight and light weight thread-multithreading
It's related to the amount of "context" associated 34 with a thread, and consequently the amount 33 of time it takes to perform a "context switch".
Heavyweight 32 threads, (usually kernel/os level threads) have 31 a lot of context (hardware registers, kernel 30 stacks, etc). So it takes a lot of time 29 to switch between threads. Heavyweight threads 28 may also have restrictions on them, for 27 example, on some OSes, kernel threads cannot 26 be pre-empted, which means they can't forcibly 25 be switched out until they give up control.
Lightweight 24 threads on the other hand (usually, user 23 space threads) have much less context. (They 22 essentially share the same hardware context), they 21 only need to store the context of the user 20 stack, hence the time taking to switch lightweight 19 threads is much shorter.
On most OSes, any 18 threads you create as a programmer in user 17 space will be lightweight in comparison 16 to the kernel space threads. There is no 15 formal definition of heavyweight and lightweight, it's 14 just more of a comparison between threads 13 with more context and threads with less 12 context. Don't forget that every OS has 11 its own different implementation of threads, and 10 the lines between heavy and light threads 9 are not necessarily clearly defined. In 8 some programming languages and frameworks, when 7 you create a "Thread" you might not even 6 be getting a full thread, you might just 5 be getting some abstraction that hides the 4 real number of threads underneath.
[Some 3 OSes allow threads to share address space, so 2 threads that would usually be quite heavy, are 1 slightly lighter]
Java standard threads are reasonably heavy 15 in comparison to Erlang threads which are 14 very light spawnable processes. Erlang demonstrates 13 a distributed finite state machine. However 12 as an example, http://kilim.malhar.net/ , a Java extension library 11 based on the Actor model of concurrency, proposes 10 a construct for light weight threads in 9 java. Instead of Thread implementing run(), a 8 Kilim thread implements from the Kilim library 7 using an execute() method. Apparently it 6 shows Java's runtime outperforms Erlang's 5 (atleast in a local environment AFAIK). Java 4 did actually have such things in the original 3 language spec called 'green threads' but 2 subsequent Java versions dropped them in 1 favor of native threads
In most systems Light weight threads are 7 the normal threads you create with the help 6 of library, like p_threads in linux.
While 5 Heavy weight, in some systems, refer to 4 a system process, with its own virtual memory 3 and a more complex structure, like information 2 about the process performance/statistics.
For 1 more information:
More Related questions