Skip to content

Instantly share code, notes, and snippets.

@JoeGlines
Created October 14, 2025 11:42
Show Gist options
  • Save JoeGlines/4272f105f0e60255240d3128e506ea83 to your computer and use it in GitHub Desktop.
Save JoeGlines/4272f105f0e60255240d3128e506ea83 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
func downloadFile(fileName string, duration time.Duration) {
fmt.Printf("Starting download: %s\n", fileName)
time.Sleep(duration) // Simulate download time
fmt.Printf("Finished download: %s\n", fileName)
}
func main() {
// Start three downloads concurrently
go downloadFile("image1.jpg", 2*time.Second)
go downloadFile("video.mp4", 3*time.Second)
go downloadFile("document.pdf", 1*time.Second)
// Wait for them to complete
time.Sleep(4 * time.Second)
fmt.Println("All downloads complete!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment