Instances of FixedOrderComparator tsis synchronized. Cov chav kawm tsis yog xov-kev nyab xeeb ntawm lub sijhawm tsim kho, tab sis nws yog xov-zoo los ua ntau qhov kev sib piv tom qab tag nrho kev teeb tsa tiav.
Puas piv piv cov xov-kev nyab xeeb?
Kev Sib Piv Feem Ntau tsis ua li ntawd, tab sis ib qho xwm txheej uas yuav tshwm sim yog siv SimpleDateFormat los sib piv Cov Kab uas sawv cev rau hnub. Hmoov tsis zoo, SimpleDateFormat nws tus kheej tsis yog xov zoo. Comparator yog ib qho kev sib txuas, nws tsis muaj cov khoom sib xws.
Puas muaj ntau txoj xov zoo?
Xov xwm nyab xeeb: Kev ua tiav yog lav kom tsis muaj kev sib tw thaum nkag los ntawm ntau cov xov ib txhij. Kev nyab xeeb raws li txoj cai: Cov xov sib txawv tuaj yeem nkag mus rau cov khoom sib txawv ib txhij, thiab kev nkag mus rau cov ntaub ntawv sib koom raug tiv thaiv los ntawm haiv neeg.
Cov chav kawm sau dab tsi yog xov zoo?
Tsuas yog ob qhov kev sau qub txeeg qub teg yog xov-kev nyab xeeb: Vector thiab Hashtable.
Is Java ArrayList xov-kev nyab xeeb?
Txhua txoj kev uas kov Vector cov ntsiab lus yog xov zoo. ArrayList, ntawm qhov tod tes, yog unsynchronized, ua rau lawv, yog li ntawd, tsis xov zoo. Nrog rau qhov sib txawv hauv siab, siv synchronization yuav ua rau muaj kev ua tau zoo. Yog li yog tias koj tsis xav tau cov xov-kev nyab xeeb, siv ArrayList.