Skip to content
GolangFix

GolangFix

Find thousands of fixes for Go Language related issues. Daily Updated!

  • All Questions
  • GoLang
  • goroutine

Tag: multithreading

October 4, 2022 GoLang

Why is Go considered partially preemptive?

Issue I am trying to get a better understanding of the definition preemptive and cooperative in the context of Go. Wiki states for preemptive multitasking In computing, preemption is the act of temporarily interrupting an executing task, with the intention

Continue reading
September 12, 2022 GoLang

Why are there more OS threads when running go simple app?

Issue When running a simple app, there are more OS threads than the max allowed by my processor. This is the sample code: package main import ( "fmt" "runtime" "time" ) func doSomething() { time.Sleep(10 * time.Minute) } func main()

Continue reading
August 24, 2022 goroutine

Best way to wake 0-N sleeping goroutines at once

Issue I’m writing a program where I start N (N is a command-line argument) worker threads, and at any time 0 to N-1 of them can be waiting on another to update a variable. What’s the best way for the

Continue reading
August 10, 2022 GoLang

Peterson's algorithm and deadlock

Issue I am trying to experiment with some mutual execution algorithms. I have implemented the Peterson’s algorithm. It prints the correct counter value but sometimes it seems just like some kind of a deadlock had occurred which stalls the execution

Continue reading
August 10, 2022 GoLang

How to find the number of threads waiting for mutex lock in Sync.Mutex?

Issue I am using this in a go subroutine a.Lock() … enter code here … a.Unlock() Is there any api to know how many threads are waiting at a.Lock()? Solution Is there any api to know how many threads are

Continue reading
August 2, 2022 GoLang

Using a GoLang Routine to Return to Multiple Threads

Issue I am building an API that can queue up requests to GET an external website and subsequently perform some work by interacting with that API. I am trying to figure out how to avoid duplicate simultaneous go routines. That

Continue reading
July 25, 2022 GoLang

Why does my program not shut down when I use goroutine in main?

Issue Context Please, read the comments in code carefully. Everything is in them. In case you have experience using discordgo The full code can be found here: https://github.com/telephrag/kubinka/tree/bug (see packages strg and main) With addition of goroutine command handlers stop

Continue reading
July 19, 2022 GoLang

Goroutines – send critical data to the single goroutine and wait for result

Issue I have many goroutines running in my application, and I have another goroutine that must handle only one request at the same period of time and then send the result back to caller. It means other goroutines should wait

Continue reading
July 7, 2022 goroutine

When will Go scheduler create a new M and P?

Issue Just learned golang GMP model, now I understand how goroutines, OS threads, and golang contexts/processors cooperate with each other. But I still don’t understand when will an M and P be created? For example, I have a test code

Continue reading
April 28, 2022 GoLang

Load data from reading files during startup and then process new files and clear old state from the map

Issue I am working on a project where during startup I need to read certain files and store it in memory in a map and then periodically look for new files if there are any and then replace whatever I

Continue reading

Posts navigation

1 2 3 … 7 Next Posts»

amazon-web-services arrays channel concurrency deadlock dictionary docker error-handling generics go go-gin go-gorm go-modules go-templates goland google-cloud-platform goroutine grpc http interface json kubernetes linux mongo-go mongodb multithreading mysql pointers postgresql protocol-buffers python reflection regex slice sql string struct testing time type-conversion types unit-testing unmarshalling visual-studio-code windows

WordPress Theme: Maxwell by ThemeZee.

Privacy Policy - Terms and Conditions