02158  Concurrent Programming - CP Mini Lab 5: Introduction to Go
Technical University of Denmark DTU
02158 Concurrent Programming        Fall 2024
CP Mini Lab 5: Introduction to Go
Home Plan Material  

Purpose

To get a first experience with the Go language.

Prerequisites

Download the Go development tools from golang.org.

It is assumed the the programs are edited in a simple text editor and executed with go run.

Instructions

  1. Fetch the file Donald.go
  2. Compile and run Donald.go with

      go run Donald.go

    [Alternatively, you may just compile the program with go build Donald.go and run the resulting Donald[.exe] program afterwards.]

  3. Add yourself to the choir, i.e. create a goroutine which prints your name 10 times.
  4. Replace the WaitGroup synchronization with a channel finished of type chan int which is being used by each goroutine. When they are done, they should send a number (any will do) on the channel. When the main process has received suffient number of messages, it should finish the program execution.

    Remember to create the channel with make(chan int) at initialization.

Enjoy!

Hans Henrik Løvengreen, Nov 15, 2024

Answers:

  1. See solution here DonaldChan.go