Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Related: Early (almost prehistoric by software timeline standards) versions of Java used a green thread implementation, but this was dropped in Java 1.1 in favour of the current native OS thread model. Some background:

https://softwareengineering.stackexchange.com/questions/1203...



Java had a quite lousy implementation of green threads, that hurt performance more than enabled parallelism. (What isn't explainable by it being early, since there were earlier green threads implementation that didn't suck. Looks like it just wasn't a priority for Java developers.)

There's nothing anywhere restricting green threads to a single OS thread. Most modern runtimes will automatically multiplex the green threads into as many OS threads as your computer can run.


> Java had a quite lousy implementation of green threads, that hurt performance more than enabled parallelism

1:N green threads (which Java had) aren't intended for parallelism and provide none. They provide concurrency only.

M:N green threads (e.g., Erlang processes) provide parallelism.


Java had a mixed model where it could use LWPs or kernel threads, and switched over around Solaris 8 because things like stat() were still blocking and had no async counterpart, so were difficult to deal with.

I dug up this fossil the other day, trying to get a fix from Sun for this very issue:

http://d.hd.org/JavaThreadsCommentToSun19980820.html


Is this solved in Go? A while back Go required programmers to use rate limiters, otherwise it would spawn unlimited kernel threads for blocking syscalls.


It's capped at 10000 threads (configurable). Note that Go uses asynchronous I/O where possible.


Rust originally supported only M:N green threads. Native thread support was added, became the default, and green thread support was eventually moved out of Rust core to a library. Here is the proposal and rationale:

https://github.com/rust-lang/rfcs/blob/0806be4f282144cfcd55b...


I think Java only started shipping native Linux thread support somewhat later, maybe in JDK 1.3.


Linux itself didn't have (working) threads until around 2003.


Linux got threads with the clone() system call in 1999. They worked but it was not a cross platform API. Though in that time most operating systems had proprietary thread APIs. Standards compliant POSIX threads came later to Linux than some other Unix systems, that much is true.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: