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
Post a Comment