func Init(main func()) {
	done := donePool.Get().(chan struct{})
	defer donePool.Put(done)
	go func() {
		defer func() {
			done <- struct{}{}
		}()
		main()
	}()
	for {
		select {
		case f := <-funcQ:
			func() {
				defer func() {
					f.done <- struct{}{}
				}()
				f.fn()
			}()
		case <-done:
			return
		}
	}
}
Init initializes the functionality for running arbitrary subsequent
functions on a main system thread.

Init must be called in the main package.
package mainthread
import (
	"runtime"
	"sync"
)
var funcQ = make(chan funcData, runtime.GOMAXPROCS(0))
func init() {
	runtime.LockOSThread()
}
type funcData struct {
	fn   func()
	done chan struct{}
}