Java??????????????????????
???????????? ???????[ 2013/6/20 10:51:33 ] ????????
????????????
??????????????synchronized???ε????????this????飬?????????????????????????????Щ???????????????
?????????????????????Э?????????????ReentrantLock??????????????????????????????????????ж????????????????????????м???????????????????????????????????ж?????????????????????????????????????????????????????
????ReentrantLock?????÷??
Lock lock=new ReentrantLock();
lock.lock();
try{
//????????
}finally{
lock.unlock();
}
???????????????з???????????????????????????????μ????????????????????????????????????????????е????????????????????????????????????е???????????????????????????????
?????????????????????
????lock()???????????
?????????????б??κ????????У????????????????????????????1.
?????????????????????????У??????????????????????1.
?????????????????????????У???????????????????????????
????tryLock??time?????????????ж?????
???????????????????????б??κ?????????У??????????б??ж??????????????????true????????????1.
?????????????????????????У???????????true????????????1.
?????????????????????????У?????????????????????????????????????????
????????????????????????ж???????
??????????????????????????????У?????true??????????л??????????false
????lockInterruptibly()???????????ж?????
???????????????????????????б??ж???????????????
?????????????б??κ????????У????????????????????????????1.
?????????????????????????У??????????????????????1.
?????????????????????????У???????????????????????????????????????????
????????????????????????ж?
????tryLock()?????????????
?????????????б??κ????????????????????????true????????????1.
?????????????????????????У???????????true????????????1.
?????????????????????????У???????????false??
????unlock()???????
???????????????????????????????????? 1????????????????? 0??????????
??????????ReentrantLock?????????????????????boolean??????????????false?????????????????????????true?????????????????????
??????ν???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????synchronized??ReentrantLock?????
?????????????synchronized??????????????????????????????ж???????????????????е??????????????ReentrantLock??
??????????д?????У????????????????е??-д?????У???ReentrantReadWriteLock.
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11