Created
October 14, 2025 11:42
-
-
Save JoeGlines/4272f105f0e60255240d3128e506ea83 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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