List the functions can stop or suspend the execution of current goroutine, and explain their differences.

Technology CommunityCategory: GolangList the functions can stop or suspend the execution of current goroutine, and explain their differences.
VietMX Staff asked 5 months ago
  • runtime.Gosched: give up CPU core and join the queue, thus will be executed automatically.
  • runtime.gopark: blocked until the callback function unlockf in argument list return false.
  • runtime.notesleep: hibernate the thread.
  • runtime.Goexit: stop the execution of goroutine immediately and call defer, but it will not cause panic.