---
title: "Comment by Ajinkya Borade on \"Go vs Java in terms of memory efficiency. Beauty of go routines and their variable stack size limit.\" | Hashnode"
description: "Im not exactly sure about Java mem stack limit and how it uses OS threads. I will post this in context of GoLang (GO) just for the sake I wanted to write and I"
url: "https://hashnode.com/posts/go-vs-java-in-terms-of-memory-efficiency-beauty-of-go-routines-and-their-variable-stack-size-limit/5c87671166eb7a457cb5a594/comment/5c9dd71ace38515309ac752b"
---

[Discussion](https://hashnode.com/posts/go-vs-java-in-terms-of-memory-efficiency-beauty-of-go-routines-and-their-variable-stack-size-limit/5c87671166eb7a457cb5a594)

Comment [Go vs Java in terms of memory efficiency. Beauty of go routines and their variable stack size limit.](https://hashnode.com/posts/go-vs-java-in-terms-of-memory-efficiency-beauty-of-go-routines-and-their-variable-stack-size-limit/5c87671166eb7a457cb5a594)

[Ajinkya Borade](https://hashnode.com/@Ajinkya)

[Mar 29, 2019](https://hashnode.com/posts/go-vs-java-in-terms-of-memory-efficiency-beauty-of-go-routines-and-their-variable-stack-size-limit/5c87671166eb7a457cb5a594/comment/5c9dd71ace38515309ac752b)

Im not exactly sure about Java mem stack limit and how it uses OS threads.

I will post this in context of GoLang (GO) just for the sake I wanted to write and I love Go, I hate Java (dont ask me why).

**goroutines** are not OS threads, but they are not exactly Green Threads as well.

Go’s mechanism for hosting goroutines is an implementation of what’s called an M:N scheduler , which means it maps M green threads to N OS threads.

Goroutines are then scheduled onto the green threads. When we have more goroutines than green threads available, the scheduler handles the distribution of the goroutines across the available threads.

[PRASHANTH H N](https://hashnode.com/@prahashnode)

[Apr 1, 2019](https://hashnode.com/posts/go-vs-java-in-terms-of-memory-efficiency-beauty-of-go-routines-and-their-variable-stack-size-limit/5c87671166eb7a457cb5a594/comment/5c9dd71ace38515309ac752b#reply-5ca1875de9cf4f914baf8ee2)

Hi @Ajinkya Can you please give a reference to "M:N scheduler" part ?

[Ajinkya Borade](https://hashnode.com/@Ajinkya)

[Apr 1, 2019](https://hashnode.com/posts/go-vs-java-in-terms-of-memory-efficiency-beauty-of-go-routines-and-their-variable-stack-size-limit/5c87671166eb7a457cb5a594/comment/5c9dd71ace38515309ac752b#reply-5ca19134e9cf4f914baf8ee6)

[PRASHANTH H N](https://hashnode.com/@prahashnode) [golang.org/src/runtime/proc.go](https://golang.org/src/runtime/proc.go)

easy to read => [ardanlabs.com/blog/2018/08/scheduling-in-go-part2…](https://www.ardanlabs.com/blog/2018/08/scheduling-in-go-part2.html) [povilasv.me/go-scheduler](https://povilasv.me/go-scheduler/)

[Ajinkya Borade](https://hashnode.com/@Ajinkya)

[Apr 8, 2019](https://hashnode.com/posts/go-vs-java-in-terms-of-memory-efficiency-beauty-of-go-routines-and-their-variable-stack-size-limit/5c87671166eb7a457cb5a594/comment/5c9dd71ace38515309ac752b#reply-5caad238dbeca9f921c49d19)

more on this [rcoh.me/posts/why-you-can-have-a-million-go-routi…](https://rcoh.me/posts/why-you-can-have-a-million-go-routines-but-only-1000-java-threads/)
