c# - Read/Write synchronizer , get the owner of the lock -


probably simple question, due lack of knowledge on c# i'm having hard time finding solution this.

here's deal, have implement semaphore 5 methods, lockread, lockwrite, releaseread, releasewrite , releaselockwriter.

the names of first 4 methods quite self-explanatory, last 1 method releases writer lock , acquires read lock atomically.

now problem here releaseread, releasewrite , releaselockwriter can called thread has acquired read or write lock, respectively.

how can know if thread owner of lock? possible solution creating id's each thread , passing them when acquiring lock , when releasing passing id again , check if id owner, there's better way of doing it.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -