Edit: Oh, apparently you all mean OS threads. So say so. (For example, in Haskell they're called threads without any implication that each one is an OS thread. Haskell's not unusual that way.)
Edit: Oh, apparently you all mean OS threads. So say so. (For example, in Haskell they're called threads without any implication that each one is an OS thread. Haskell's not unusual that way.)
In this case, threads refer to not-a-process units of execution in an operating system. For whatever its worth, Wikipedia defines threads as:
the smallest sequence of programmed instructions that
can be managed independently by an operating system
scheduler.
I think that's also the commonly accepted definition: that threads are related to the OS scheduler.But that's just a detail. In reality, goroutines are threads; they're just userland, non-preemptive threads. Similar constructions have been available, even to C programmers, for well over a decade (and probably much longer).
Of course they aren't called threads there, either (probably for the same reason as they aren't called threads in Go)
Programming language support for threading predates direct operating system support (at least in mainstream operating systems) by a lot of years, from what I can tell.
As I mentioned, knowing the difference is actually a good thing so your post is really helpful. My point is just that the two concepts are so intertwined and overlapping that I think it is silly for someone to correct someone's terminology on this (as Jabbles did, though I admit I share some of his(?) other concerns with the OP), particularly in cases where it is clear the person is pretty familiar with goroutines and how they operate.
However the more salient point here is the OP was either being lazy by saying "goroutines are not threads", or actually doesn't understand the concept of lightweight threads. Along the lines of Rob Pike's own explanation on the matter, he maybe should have said "goroutines provide concurrency but not parallelization".
If they are multiplexed on several threads, then they also provide parallelization.
It is actually common for people to talk about green threads (http://en.wikipedia.org/wiki/Green_threads) in the same vain as OS threads.
It's an important distinction between using many (read: hundreds) of OS threads in a single process isn't performant, while using hundreds or even tens of thousands of goroutines is just fine.
Also, you can easily run 10s of thousands of kernel threads (provided you decrease the threads' stack size).