11 - Quiz¶
-
Your name:
-
Your VT email:
When a Go program starts, which statement is correct?
- A. Multiple goroutines are created automatically based on CPU cores.
- B. One OS thread and one goroutine are created per package.
- C. Only the main goroutine exists initially.
- D. No goroutine exists until
gois used.
Which of the following best describes the forkâjoin pattern?
- A. A goroutine repeatedly spawns itself.
- B. Goroutines communicate only through shared memory.
- C. Threads are reused in a fixed pool.
- D. Multiple concurrent tasks are started and later synchronized.
What is the main purpose of sync.WaitGroup?
- A. To prevent race conditions.
- B. To enforce mutual exclusion.
- C. To wait for a collection of goroutines to finish.
- D. To limit the number of goroutines created.
Why must wg.Add(1) typically be called before starting the goroutine?
- A. Otherwise a subsequent
wg.Wait()could happen beforewg.Add(1). - B. Otherwise the new goroutine cannot access the variable
wg. - C. Otherwise the goroutine runs sequentially.
- D. Otherwise the program will not compile.