Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danitilahun/go_concurrency
Go_Concurrency: A repository showcasing Go's concurrency prowess through practical implementations using WaitGroup, channels, and atomic operations. Explore race condition mitigation and advanced patterns for effective concurrent programming.
https://github.com/danitilahun/go_concurrency
atomic channels concurrency go race-conditions testing waitgroup
Last synced: about 4 hours ago
JSON representation
Go_Concurrency: A repository showcasing Go's concurrency prowess through practical implementations using WaitGroup, channels, and atomic operations. Explore race condition mitigation and advanced patterns for effective concurrent programming.
- Host: GitHub
- URL: https://github.com/danitilahun/go_concurrency
- Owner: Danitilahun
- Created: 2023-12-26T15:15:09.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2023-12-28T17:39:37.000Z (10 months ago)
- Last Synced: 2024-01-25T18:08:15.895Z (10 months ago)
- Topics: atomic, channels, concurrency, go, race-conditions, testing, waitgroup
- Language: Go
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go Concurrency
## CPU Information Retrieval Commands on Windows
- `wmic cpu get NumberOfLogicalProcessors`: Provides the count of logical processors (cores) available on the Windows system.
- `wmic cpu get NumberOfCores`: Offers the count of physical cores available on the processor.## Definitions
- **Concurrency**: The capability of an application to handle multiple tasks or processes simultaneously by interleaving their execution.
- **Parallelism**: Simultaneous execution of multiple tasks genuinely running at the same time using multiple CPU cores.## Fork-Join in Go (Golang)
"Fork-join" in Go refers to dividing a task into smaller sub-tasks (forking), executing them independently, and then merging the results (joining) to produce the final output.
- **Fork**: Breaking a task into smaller units for concurrent or parallel execution.
- **Join**: Merging the results from individual tasks to form the final result.## Common Challenges in Concurrent Programming
1. **Race Conditions**: Unpredictable behavior due to multiple threads accessing shared resources without synchronization.
2. **Deadlocks**: Tasks waiting indefinitely for each other, halting progress.
3. **Livelocks**: Continuous state changes without resolution, preventing progress.
4. **Resource Starvation**: Inability to access necessary resources due to monopolization by other tasks.
5. **Synchronization Overhead**: Introduction of synchronization mechanisms impacting performance and complexity.## Example Code
```go
package mainimport (
"fmt"
"sync"
)func main() {
var wg sync.WaitGroup
wg.Wait()
fmt.Println("Wait() executed immediately")
}
```