Publicvoidtest(inti)
{
Lock(this)
{
If(i10)
{
I- - ;
Test(i);
}
}
}
Answer: Won't produce dead lock, (but having a bit Int is delivered by the value, change every time so it is a carbon only, because this won't appear,lock up to death. But if change Int,do an Object, so dead lock can happen)
Ask why to change Int do an Object, so dead lock can happenWhat Object delivers is an address what the lock decides also is this addressThis paragraph of code won't produce dead lock, because be current line,Cheng Suo is decided. Lock is actual be to pass the Enter of Monitor and Exit to realize a lock to decide. This lock is his lock, the dispute of the platoon is current line Cheng, invalid to current line Cheng. Be the same as Cheng of a gleam of to call Enter for many times below the situation that does not prevent is lawful; But identical numerary Exit must be called before the other line Cheng that awaits on this object cancels to prevent. Up
没有评论:
发表评论