goroutine - OS Threads in a Go Program -


I am using 1.3.3 I am trying to understand when I go to new threads I have the following two programs Are:

Program 1:

  Package main fax main () {for ;; {}}  

Program 2:

  Package main import ("sync") fenc justrun (wg * sync.WaitGroup) {for ;; {} Wg.Done ()} func main () {var wg sync.WaitGroup gor (& amp; wg) wg.Wait ()}  

In the activity monitor I see that program There are two threads in 1 and 3 threads for the program 2. I have many questions:

  1. What are these 2 threads in program 1? I think that is for a "main", but what's the other for this?
  2. In Program 2, once I tell wg.Wait () that the number of threads is 3. I was guessing Program 2 was the same number of threads as program 1. My understanding is that one thread with main () format P1 is going on in M1, will run in the race of Gorontane P1. I have read somewhere that the oldest gourmet in the sync package does not use a thread because they are blocked due to them. If this is the case, then Gourmet should go in conjunction with P1 and M1, and there should be no need for a new thread. Is wg.Wait () a thread blocking call?

Any help is appreciated.

The rules are GOMAXPROCS for user-level code Threads will arise. From documentation:

GOMAXPROCS variable limits the number of operating system threads that can execute user-level code simultaneously.

But note:

There is no limit to the number of stations that can be blocked in the system call for go code; They do not count against the GOMAXPROCS borders.

is dependent on the runtime, and the implementation (and the version) is specific; perhaps more goratians are running than you are feeling;


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -