Skip to content

Instantly share code, notes, and snippets.

@ierhalim
Created December 27, 2020 12:06
Show Gist options
  • Select an option

  • Save ierhalim/ebc72eede643bc2fc6b3122c984e0f81 to your computer and use it in GitHub Desktop.

Select an option

Save ierhalim/ebc72eede643bc2fc6b3122c984e0f81 to your computer and use it in GitHub Desktop.
Y205 Paralel programlama
var task = Task.Run(() =>
{
Random rnd = new Random();
while (true)
{
try
{
readerWriterLock.EnterUpgradeableReadLock();
if (rnd.Next(5) == 2)
{
try
{
readerWriterLock.EnterWriteLock();
value += rnd.Next(10);
}
finally
{
readerWriterLock.ExitWriteLock();
}
}
Console.WriteLine(value);
Thread.Sleep(5000);
}
finally
{
readerWriterLock.ExitUpgradeableReadLock();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment