提高快取訪問和處理的併發度,在很多快取應用和io應用中有很多使用場景。
一、io當中寫資料的資料快取,保證socket在write資料的時候,執行緒仍然可以向輸出佇列outputbuffer當中新增要寫出的資料
二、在資料庫快取log寫入硬碟的過程中,使用快照技術,比如changed是要flush進硬碟的資料庫修改,如果直接將整個flush過程鎖死,其他資料庫事務將暫停,效率低下,解決辦法,將changed內容轉移到snapshot中,重新new 乙個物件給changed當中,在snapshot當中慢慢將資料flush進資料庫,此時需要兩個所
flushreadwritelock 用於鎖changed
snapshotreadwritelock 用於訪問snapshot內容(snapshot內容相當於已經是資料庫當中的內容了,get資料的時候在cache當中不存在的時候首先在snapshot當中進行find)
synchronized的幾種加鎖方式
public class synchronizedtest catch interruptedexception e public static void main string args start new thread start 此處列舉的是不同例項呼叫的情況 此處列舉的是同一例項呼叫的情況 ...
synchronized的幾種加鎖方式
public class synchronizedtest catch interruptedexception e public static void main string args start new thread start 此處列舉的是不同例項呼叫的情況 此處列舉的是同一例項呼叫的情況 ...
引用型別改變值的問題
var arr1 marry split var arr2 arr1.reverse var arr3 blues split arr2.push arr3 console.log arr1 y r r a m b l u e s console.log arr2 y r r a m b l u e...