Skip to content

14 - Quiz

  • Your name:

  • Your VT email:


Which statement best defines a race condition?

  • A. Two goroutines running at the same time
  • B. A program that runs slowly because of synchronization
  • C. A goroutine that finishes before another goroutine
  • D. A program whose result depends on the timing of concurrent operations

Which part of a program is called a critical section?

  • A. Code that performs input/output operations
  • B. Code that creates new goroutines
  • C. Code that accesses shared variables and must not run concurrently
  • D. Code that runs on the main goroutine

What is the main purpose of a sync.Mutex?

  • A. To ensure multiple goroutines run in parallel
  • B. To increase CPU utilization
  • C. To schedule goroutines across CPUs
  • D. To guarantee that only one goroutine executes a critical section at a time

Why is the following operation unsafe in concurrent programs?

balance = balance + amount
  • A. It performs multiple steps that can interleave with other goroutines
  • B. Arithmetic operations are not allowed in goroutines
  • C. Go prevents updating shared variables
  • D. The compiler removes the statement