title: Forcing goroutines into the same thread
body: <p>Is there a way to ensure that a goroutine will run only in a specific OS thread? For example, when GUI operations must run in the GUI thread, but there might be multiple goroutines running GUI code.</p>
  
  <p><code>GOMAXPROCS(1)</code> does the job technically, but that defeats the purpose of multithreading.</p>
  
  <p><code>LockOSThread()</code> works too, but that prevents any other goroutine from running in that thread as well.</p>
  
  <p>Is there a way to do this, or must everything that requires the same thread also run in the same goroutine?</p>