Skip to content

Race condition in sample code #9012

Open
@ceciliachan1979

Description

@ceciliachan1979

Here we have the code like this:

semaphore.Release(3);
Console.WriteLine("{0} tasks can enter the semaphore.",
semaphore.CurrentCount);

Isn't that a race condition? It could happen that once the semaphore is released, the count can change right away by other threads?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri3Indicates issues/PRs that are low priorityarea-System.ThreadinguntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions