Puas yog maps xov muaj kev nyab xeeb?
Puas yog maps xov muaj kev nyab xeeb?

Video: Puas yog maps xov muaj kev nyab xeeb?

Video: Puas yog maps xov muaj kev nyab xeeb?
Video: Xov Xwm 6/17/23 (Part 2): Kev Tsis Haum Xeeb Russia/Ukraine Hnub 479 Muaj Kev Puas Ntsoog Ntau Yam 2024, Hlis ntuj nqeg
Anonim

1. Txheej txheem cej luam. Maps yog ib txwm yog ib qho ntawm feem ntau dav style ntawm Java sau. Thiab, qhov tseem ceeb, HashMap tsis yog ib qho xov - nyab xeeb kev siv, thaum Hashtable muab xov - kev nyab xeeb los ntawm kev ua haujlwm synchronizing.

Tib neeg kuj nug, Golang maps xov puas nyab xeeb?

Tsis yog xov - nyab xeeb (los yog concurrent nyab xeeb ) thaum nyeem ntawv rau / sau yuav tshwm sim nrog ntau tshaj ib qho kev tawm tswv yim. Qhov no yog vim li cas tus qauv tsev qiv ntawv muab ob peb yam cuab yeej ntawm koj pov tseg hauv daim ntawv ntawm synchronization primitives.

thread safe txhais li cas? Xov kev ruaj ntseg yog lub computer programming tswvyim muaj feem xyuam rau multi- xov code. Xov - nyab xeeb code tsuas manipulates sib koom cov ntaub ntawv qauv nyob rau hauv ib tug yam uas xyuas kom meej tias tag nrho cov xov coj tus cwj pwm kom zoo thiab ua tiav lawv cov qauv tsim tshwj xeeb yam tsis muaj kev sib cuam tshuam.

Ib tug kuj yuav nug, yog ConcurrentHashMap muab xov zoo?

ConcurrentHashMap chav kawm yog xov - nyab xeeb i.e. ntau xov tuaj yeem ua haujlwm ntawm ib yam khoom tsis muaj teeb meem. Nyob rau ib lub sij hawm twg tus naj npawb ntawm xov muaj feem xyuam rau kev nyeem ntawv ua haujlwm yam tsis muaj xauv lub ConcurrentHashMap khoom uas tsis muaj nyob rau hauv HashMap. Default concurrency-level ntawm ConcurrentHashMap yog 16.

Puas yog unmodifiableMap xov zoo?

unmodifiableMap (DeliverersMod); nrog rau cov haujlwm ua ntej uas daim ntawv qhia muaj neeg nyob. Yog li koj code yog xov nyab xeeb thiab koj txoj kev getDeliverers yuav rov qab qhov tshwm sim raws li qhov tseeb version ntawm koj daim ntawv qhia.

Pom zoo: