Why Goroutines Scale: Stack Growth, Compiler Tricks, and Context Switching
dev.to·1w·
Discuss: DEV
🔵Go
Preview
Report Post

Threads in Languages like c++ and JAVA

In the above mentioned languages, threads are a means of concurrency that takes a lot of cpu time in context switching and takes a relatively huge memory at the time of their creation. A single thread takes ~ 1 MB. Therefore, if you were to spawn 100,000 threads, you would need about 100 GB of RAM, which is not economically feasible for most of software projects. Also for maintaining concurrency, CPU generally uses timeslicing, to give equal number of cpu cycle to each thread. But while doing this, the CPU have to perform context switching. This whole thing is quite expensive, in terms of time because of saving current thread details in TCB(Process Control Block), loading the new thread TCB in memory and context switches destroy cache loc…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help