Requirements:
Main (I =; I <; I ++ = Thread (ThreadStart ();. lockTest (List <> numberArr = List <> LockTest (++ index = numberArr. findIndex (t => t = +); +Number pre-occupied by multiple concurrent locks
The concurrency preoccupation interval is one time in milliseconds, and the preoccupation number consumes one time in seconds. The above code changes this parameter to get different results.
]----------------------------------------------------
Main (I =; I <; I ++ = Thread (ThreadStart (); Base (). lockTest (List <> numberArr = List <> LockTest (+ index = numberArr. findIndex (t => t = (Monitor. tryEnter (numberArr [index],) ++); ++Multi-concurrency preoccupation Number of Monitor
Summary:
Added the wait time in the Monitor version to better avoid deadlocks.
The above two locks are only the LockTest method, and other methods will not be intervened.