A thread-safe implementation of the classic Reader-Writer synchronization problem in .NET 9.
Download the latest release for your operating system from the Releases page:
- Windows: 
ReaderWriter-win-x64.zip - Linux: 
ReaderWriter-linux-x64.tar.gz - macOS: 
ReaderWriter-osx-x64.tar.gz 
Extract and run:
# Windows
ReaderWriter.ConsoleApp.exe
# Linux/macOS
./ReaderWriter.ConsoleApp# Clone and build
git clone https://github.com/yourusername/readerwriter.git
cd readerwriter
dotnet build
# Run tests
dotnet test
# Run simulation
cd ReaderWriter.ConsoleApp
dotnet runDemonstrates concurrent access patterns where:
- Multiple readers can access a shared resource simultaneously
 - Writers get exclusive access (no other readers or writers)
 - All access is thread-safe and logged
 
ReaderWriter.sln
├── ReaderWriter.Core/          # Thread-safe reader-writer logic
├── ReaderWriter.ConsoleApp/    # Simulation host
└── ReaderWriter.Tests/         # Unit tests
{
  "SimulationSettings": {
    "NumberOfReaders": 10,      # Concurrent readers
    "NumberOfWriters": 3,       # Concurrent writers
    "SimulationDurationSeconds": 30
  }
}./ReaderWriter.ConsoleApp --readers 20 --writers 5 --duration 60
# or short form
./ReaderWriter.ConsoleApp -r 20 -w 5 -d 60# Windows
set SimulationSettings__NumberOfReaders=25
set SimulationSettings__NumberOfWriters=3
set SimulationSettings__SimulationDurationSeconds=60
ReaderWriter.ConsoleApp.exe
# Linux/macOS
export SimulationSettings__NumberOfReaders=25
export SimulationSettings__NumberOfWriters=3
export SimulationSettings__SimulationDurationSeconds=60
./ReaderWriter.ConsoleApp[20:42:57 INF] Writer 2 attempting to acquire write lock
[20:42:57 INF] Writer 2 acquired write lock
[20:42:57 INF] Writer 2 wrote data: Data from Writer 2 - Item 1. Total items: 1
[20:42:57 INF] Writer 2 released write lock
[20:42:57 INF] Reader 4 acquired read lock
[20:42:57 INF] Reader 7 acquired read lock
[20:42:57 INF] Reader 4 read data: Data from Writer 2 - Item 1
[20:42:57 INF] Reader 7 read data: Data from Writer 2 - Item 1
.\ReaderWriter.ConsoleApp\localrun.ps1bash simple-run.sh# Windows (self-contained, no .NET required)
dotnet publish -c Release -r win-x64 --self-contained -p:PublishSingleFile=true
# Linux (self-contained, no .NET required)
dotnet publish -c Release -r linux-x64 --self-contained -p:PublishSingleFile=true
# macOS (self-contained, no .NET required)
dotnet publish -c Release -r osx-x64 --self-contained -p:PublishSingleFile=true
# Framework-dependent (smaller size, requires .NET 9 runtime)
dotnet publish -c Release -r win-x64 --self-contained false -p:PublishSingleFile=trueThis project uses GitHub Actions to automatically:
- Build and test on Windows, Linux, and macOS
 - Run the simulation with various configurations
 - Create platform-specific releases
 - Perform code analysis and security scanning
 
Every push and pull request triggers the full build pipeline, ensuring cross-platform compatibility.
- Synchronization: 
ReaderWriterLockSlim(.NET built-in) - Logging: Serilog → Console + Daily rolling files
 - DI Container: Microsoft.Extensions.DependencyInjection
 - Testing: xUnit with high concurrency scenarios
 - Patterns: SOLID, DDD, Dependency Injection
 - Target Framework: .NET 9
 - Cross-Platform: Runs on Windows, Linux, and macOS
 
- ✅ Basic read/write operations
 - ✅ Writer blocks concurrent readers
 - ✅ Writer blocks concurrent writers
 - ✅ Multiple readers run concurrently
 - ✅ Data integrity under high concurrency
 - ✅ Cancellation and cleanup
 - ✅ Cross-platform compatibility
 
- Readers can operate concurrently for maximum throughput
 - Writers get exclusive access to maintain data consistency
 - Lock acquisition timeouts prevent deadlocks
 - Configurable operation delays simulate real-world scenarios
 
AGPL - See LICENSE.txt
Note: Implementation generated by Claude Opus 4 from specification by Gemini 2.5 Pro