Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Косторной Дмитрий #27

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Kostornoj-Dmitrij
Copy link

No description provided.

}

public override long ComputeFactorial(int number)
{
throw new System.NotImplementedException();
_rwLock.EnterUpgradeableReadLock();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почему именно upgradeable?

Comment on lines 34 to 35
Parallel.For(0, WritersThreads, i => resource.Write($"Data {i}"));
Parallel.For(0, ReadersThreads, _ => resource.ComputeFactorial(FactorialNumber));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Parallel.For под капотом передаёт все задачи в тредпул. А значит число потоков получится меньше требуемого
  2. Исполнение Parallel.For закончится тогда, когда выполнятся все запущенные им задачи. Получается, сначала отработают все писатели, а уже потом все читатели

@Kostornoj-Dmitrij
Copy link
Author

Внёс изменения

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants