org.sonar.plugins.csharp.S3889.html Maven / Gradle / Ivy
Why is this an issue?
Thread.Suspend
and Thread.Resume
can give unpredictable results, and both methods have been deprecated. Indeed, if
Thread.Suspend
is not used very carefully, a thread can be suspended while
holding a lock, thus leading to a deadlock.
There are other synchronization mechanisms that are safer and should be used instead, such as:
-
Monitor
provides a mechanism that synchronizes access to objects.
-
Mutex
provides a mechanism that synchronizes interprocess access to a protected resource.
-
Semaphore
provides a mechanism that allows limiting the number of threads that have access to a protected resources concurrently.
-
Events
enable a class to notify others when something of interest occurs.
Resources
Documentation
- Thread.Resume Method
- Thread.Suspend Method
- Monitor Class
- Mutex Class
- Semaphore Class
- Events Programming Guide
- lock statement
Articles & blog posts
© 2015 - 2024 Weber Informatics LLC | Privacy Policy