entrant是什么意思,entrant中文翻譯,entrant發(fā)音、用法及例句
?entrant
entrant發(fā)音
英:[?entr?nt] 美:[??ntr?nt]
英: 美:
entrant中文意思翻譯
n. (參加比賽的)競賽者, 新就業(yè)者, 新成員
entrant常見(jiàn)例句
1 、a re - entrant angle───凹角
2 、Results show that the entrant may has lower or higher incentive of compatibility in contrast with the social optimum because of different switching costs.───本文得出的主要結論是相對社會(huì )最優(yōu)而言。由于轉移成本的不同,進(jìn)人廠(chǎng)商可能兼容性選擇不足。也可能過(guò)度兼容。
3 、Each entrant agrees to be bound by the provisions of this announcement, by the regulations of his/her licensing authority and by the decisions of the ARRL Awards Committee, acting for the IARU International Secretariat.───參賽者必須同意遵守前述的比賽規則、自己執照所規范的事項、ARRL獎狀委員會(huì )因應IARU國際秘書(shū)處的要求所做的決定。
4 、If necessary, the Organiser may change the location of the sculpture after coming to an agreement with the entrant who has been selected for commissioning.───在有需要的時(shí)候,主辦單位可與獲委約者協(xié)議更改雕塑擺放位置。
5 、sequential entrant───序貫進(jìn)入
6 、Also the news (by Wang Yan) corporate management specialized present becomes most receives our province from to test the specialty which the entrant pursues holds.───又訊(記者王巖)公司管理專(zhuān)業(yè)目前成為最受我省自考報名者追捧的專(zhuān)業(yè)。
7 、direct trade entrant───直接入職海員
8 、The late entrant will not only have the advantage of being a fresh face.───優(yōu)勢不僅僅在于擁有一張新面孔。
9 、Overall it can be said that a new entrant to the New Zealand business environment is unlikely to be met with any surprises about basic contract laws, contract enforceability or Court procedure.───總體而言,置身紐西蘭的商貿環(huán)境,即使是涉獵未深的新手,也不會(huì )在基本的合同法、履約及法庭程序方面有任何迭破眼鏡大出意料的事情發(fā)生。
10 、HOW assumes all entries are original and are the works and property of the entrant, with all rights granted therein.───HOW假設所有參賽作品都是原創(chuàng )的,是參賽者的勞動(dòng)以及所有,所有權利已經(jīng)認可。
11 、Meanwhile, the potential entrant will produce the extreme product to hold on peripheral consumers.───即表示,潛在進(jìn)入者將會(huì )生產(chǎn)甜度較極端的產(chǎn)品來(lái)吸引在邊緣市場(chǎng)的客戶(hù)。
12 、At the same time, however, this kind of small business face the entrant threat from the potential competitor due to the low entrant barrier or mobility barrier.───同時(shí),由于小企業(yè)自身條件的限制和我國特定的知識產(chǎn)權保護現狀,這類(lèi)企業(yè)面臨著(zhù)潛在競爭者的進(jìn)入威脅和無(wú)差異化的價(jià)格競爭。
13 、Please label all CDs with the entry title, running time and entrant(s)’ name(s).───請於光碟的標籤上列明參賽作品名稱,播放時間及參賽者姓品。
14 、Second-mover Advantages in Technological Innovation and Market Entrant───技術(shù)創(chuàng )新和產(chǎn)品開(kāi)發(fā)競爭中的跟隨者優(yōu)勢
15 、In China,the rapid development of mobile phone manufacturing industry has appealed many enterprises.However,the entrant will face kinds of barriers to the market entry.───中國移動(dòng)**制造業(yè)的迅猛發(fā)展對大批企業(yè)產(chǎn)生了吸引力,但是新進(jìn)入企業(yè)將要面臨各種市場(chǎng)進(jìn)入壁壘。
16 、In either case the entrant would be at a cost disadvantage───不管是何種情況,加入的廠(chǎng)商都處于成本劣勢。
17 、The Capital Investment Entrant Scheme has been well received and since its implementation last year, overseas Chinese and foreign nationals have applied to reside in Hong Kong.───去年推出受歡迎的資本投資者入境計劃以來(lái),已陸續有海外華人和外籍人士申請來(lái)香港居住。
18 、entrant firm───新開(kāi)商號新公司
19 、Another touted 2010 entrant was Ray Mallock Ltd (RML), currently involved with Le Mans racing and the British and World touring car championships.───另一個(gè)是2010年入射線(xiàn)馬洛克有限公司(RML),目前參與的勒芒賽車(chē),并在英國和世界房車(chē)錦標賽.
20 、Entrant military───大學(xué)新生
21 、Based on the medals wined by entrant countries joining nearly four Olympic Games, the medal distributing rules of Olympic Games were analyzed with Markov method, and predicted for the next Olympic Games.───以近4屆奧運會(huì )各參賽國獎牌數量為研究對象,運用Markov方法,分析了奧運會(huì )主要參賽國獎牌變化規律,并對下一屆奧運會(huì )獎牌分布情況進(jìn)行了預測.
22 、The study develops a novel approach that uses the entrants' product portfolios to infer a potential entrant's capability relevance.───我們使用了一種新的方法,即使用潛在進(jìn)入者的產(chǎn)品組合來(lái)推斷企業(yè)相關(guān)能力。
23 、doubly re entrant winding───雙口式繞組
24 、Further, once a critical mass of customers is signed up on the Community, it becomes far more cost effective for the entrant to build a new "Hot Spot".───另外,一旦有足夠數量的客戶(hù)簽訂了關(guān)于社會(huì )變得更有成本效益的筆試建立新的"熱點(diǎn)".
25 、And the new entrant in the market hold by a incumbent firms will take higer technology risk in order to gain market share when its innovation product is incompatible with the incumbent"s.───另外,已有市場(chǎng)的新進(jìn)入者的創(chuàng )新產(chǎn)品與在位廠(chǎng)商不兼容的情況下,為了有效的進(jìn)入市場(chǎng),必須承擔更高的風(fēng)險;
26 、new entrant───新生
27 、As the world's most competitive entrant into manufacturing and a magnet for foreign direct investment, it can afford to open its market to the products of the world.───作為世界上最富有競爭力的制造業(yè)和外國直接投資的吸鐵石,中國有能力把其市場(chǎng)向全世界產(chǎn)品開(kāi)放。
28 、One new entrant was astounded by this procedure.───新加入的合營(yíng)者會(huì )被這些程序給弄糊涂了。
29 、market entrant───產(chǎn)品開(kāi)發(fā)
30 、HOW is not liable for any copyright infringement on the part of the entrant.───對于產(chǎn)品的任何侵權行為,HOW將不負責。
31 、College entrants only today, it was on the website.─── 今天只有大學(xué)生才能參賽 網(wǎng)站上寫(xiě)著(zhù)呢
32 、Lahore-based Siddiqui runs the 100 and 200 metres but as a wild card entrant she is allowed to compete in only one event and so will be lining up for the 100m heats in Beijing.───來(lái)自拉合爾的西迪基是女子100米和200米短跑運動(dòng)員,但作為一名“外卡”選手,她只能參加一個(gè)項目。在本屆奧運會(huì )上,西迪基將參加100米短跑項目比賽。
33 、First the success of entrant increases trade of online page game low the feature that enters a doorsill, stimulated a large number of small-sized atelier to entered webpage game industry 2008.───先進(jìn)入者的成功加上網(wǎng)頁(yè)游戲行業(yè)低進(jìn)入門(mén)檻的特征,刺激了大量小型工作室在2008年進(jìn)入了網(wǎng)頁(yè)游戲行業(yè)。
34 、another new entrant into the multimedia market───多媒體市場(chǎng)的另一個(gè)新成員
35 、new-market entrant───新市場(chǎng)進(jìn)入者
36 、You have to love a newer industry entrant like HP stepping up and within five years buying their way into the pressroom floor by acquiring Indigo.───你必須愛(ài)一個(gè)新的產(chǎn)業(yè)進(jìn)入,惠普加強和五年內購買(mǎi)的方式進(jìn)入新聞發(fā)言收購靛藍。
37 、re entrant gas cooling───再入式氣體冷卻
38 、This form should be completed by entrant in BLOCK letters, all the information should be submitted in both Chinese and English. If there is insufficient space, please use separate sheets.───本參加表格須由參賽單位以正楷填寫(xiě),并提供中文及英文的資料。如有需要,請以另頁(yè)填寫(xiě)并一并遞交。
39 、Entrant agrees and undertakes to accept and be responsible for all such liability arising therefrom.───參賽者同意及承諾會(huì )接受及為所有該等由此而起的責任負責。
40 、NWFB,a new entrant to the bus service market,was granted a five-year licence to operate from September 1,1998,to July 31,2003.───新巴是投入巴士服務(wù)市場(chǎng)的新公司,擁有為期五年的專(zhuān)營(yíng)權,由1998年9月1日至2003年7月31日為止。
41 、The member passes ceaseless development entrant only, and the group always is achieved oddly a certain quantity of ability promotion, enjoy more prize deduct a percentage from a sum of money.───會(huì )員只有通過(guò)不斷發(fā)展新會(huì )員,且團隊總單數達到一定數量才能晉級,并享受更多的獎金提成。
42 、Major Jack joined the army as a boy entrant and worked his way up───杰克少校是少年入伍,后來(lái)逐步升上去的。
43 、En entrant à mon service, vous faites v?u de le protéger lui de même que ma famille du moindre danger.─── 現在我交給你一份差事 那就是保護我的兒子 確保他和我的家人安全無(wú)虞
44 、Every piece of artwork submitted must be the original work of the entrant who should ensure there is no infringement of the rights (including copyright) of others.───參賽作品必須為參賽者本人的原創(chuàng )作品,并無(wú)侵犯他人的權益(包括版權)。
45 、The organisers will render the entrant liable to forfeiture of any title and prize when infringement of any rules and regulations.───如果參賽者及/或其作品違反任何相關(guān)條款及細則,主辦機構將考慮取消其參賽或得獎資格。
46 、"A rare pedigreed entrant in a summer of mules."───在一群夏季影片的騾子里,這是一匹罕見(jiàn)的純種馬.
47 、If the entrant has no proper travel document acceptable for traveling to Hong Kong, an entry permit will be issued instead.───倘投資者沒(méi)有適當的來(lái)港認可旅行證件,入境處會(huì )發(fā)予進(jìn)入許可。
48 、NWFB, a new entrant to the bus service market, was granted a five-year licence to operate from September 1, 1998, to July 31, 2003.───新巴是投入巴士服務(wù)市場(chǎng)的新公司,擁有為期五年的專(zhuān)營(yíng)權,由一九九八年九月一日至二零零三年七月三十一日為止。
49 、Thus, if greater profits produce a strong (weak) desire for the incumbent to increase its R&D level, the entrant will respond by sharply decreasing (increasing) its R&D level.───因此,如果高收益使現有經(jīng)營(yíng)者產(chǎn)生強烈的(淡薄的)意愿去提升他的研發(fā)水平,進(jìn)入者將會(huì )通過(guò)急劇的增加(減少)其研發(fā)水平來(lái)回應。
50 、"The fact that there is an entrant like that saying that there are legitimate alternatives to Cisco out there is pretty good.It causes a lot of customers to really begin to look at other alternatives.───“事實(shí)上,有一個(gè)參賽者一樣,說(shuō)有是合法的替代品,思科有很不錯,它的成因有很多客戶(hù)要真正開(kāi)始研究其他替代品” 。
51 、Any new entrant will obtain grandfathering rights over the relevant slots once it has operated a route for a predetermined period.───任何新航空公司一旦在事先確定的時(shí)期內運行一條航線(xiàn),都將獲得相關(guān)航線(xiàn)的終身運營(yíng)權。
52 、Effect of the New Entrant on the Efficiency of Supply Network───新成員的加入對供應商網(wǎng)絡(luò )效率的影響分析
53 、Mainly, we introduce the powerful competitor China Unicom, the only replacer PHS and the formidable potential entrant China Telecom.───在潛在進(jìn)入者方面,主要分析了中國電信。
54 、They characterize the conditions for the entrant’s innovation versus imitation decision to reveal information about future rewards to the incumbent.───他們對進(jìn)入者的創(chuàng )新和模仿的決策條件進(jìn)行了描述,從而顯示現有經(jīng)營(yíng)者的未來(lái)收益信息。
55 、We also find that firms with larger assets have better chance to grow up and maintain their ranking within top 100 as compared to new entrant to top 100.───在退出百大的淘汰率方面,以1970年的百大企業(yè)作基準,計算其5年、15年及30年的淘汰率,發(fā)現淘汰率呈逐年上升的趨勢。
56 、How to forecast sales of an early entrant to market?───如何預測市場(chǎng)早期進(jìn)入者的銷(xiāo)售呢?
57 、Garcia, I want you to run the entrants' names.─── 加西亞 我想讓你查查參賽者的名字
58 、Abstract: This paper researches second-mover advantages in technological innovation and market entrant in duopoly market.───文章摘要: 本文研究了雙頭壟斷市場(chǎng)技術(shù)創(chuàng )新和新產(chǎn)品開(kāi)發(fā)中的跟隨者優(yōu)勢。
59 、Over the years, Nederburg has won over 200 awards at the International Wine and Spirits Competition in London, making it the most successful South African entrant by far.───多年來(lái),該酒園在倫敦國際葡萄酒與烈酒比賽中獲得的各種獎項多達200多次,被譽(yù)為南非迄今為止最成功的酒園。
60 、If the commissioned entrant decides to make such connection, they should include the necessary equipment in the sculpture proposal and to cover the cost in the budget if commissioned.───如要進(jìn)行是項連接,獲委約者須將所需的儀器列入提案,并將有關(guān)開(kāi)支包括在制作費用預算之內。
61 、Eddy: Yes, she is the first female wild card entrant to ever reach the semifinals in Wimbledon history!───哦,我還真不知道她是歷史上第一位進(jìn)入溫布爾登公開(kāi)賽半決賽的外卡選手呢。
62 、timing of new industry entrant───產(chǎn)業(yè)進(jìn)入時(shí)機
63 、He applied for entrant to university 3 years ago.───3年前他申請參加大學(xué)入學(xué)考試。
64 、US-bused entrant───來(lái)自美國的參賽者
65 、Entrant must complete the entry form; the organizer reserves the right to disqualify any incomplete or misstated entries.───參賽者須填寫(xiě)所有表格之資料,如有任何遺漏或隱瞞,主辦機構有權取消其參賽資格。
66 、Entries must originate as photographs (image-captures of objects via light sensitivity) made by the entrant on photographic emulsion or acquired digitally.───作品必須是作者原創(chuàng ),作品應是使用感光膠片或數碼相機所攝.
67 、The authors establish that when the incumbent is more aggressive in research and development (R&D), this negatively affects the entrant’s marginal return on R&D.───作者證實(shí),當現有經(jīng)營(yíng)者的研發(fā)能力更具競爭力的時(shí)候,會(huì )對市場(chǎng)進(jìn)入者的邊際研發(fā)回報產(chǎn)生消極的影響。
68 、The cost of Third Party Bodily injury insurance is the responsibility of the Entrant.───參賽者自行承擔人身傷害保險費用.
69 、SAKU, Japan: Winding past rice paddies and lazily blowing its whistle along bubbly creeks, a two-car train in rural northern Japan is the latest entrant in the battle against global warming.───佐久,日本:纏繞過(guò)去稻田和懶洋洋吹了哨子泡沿著(zhù)小溪,一兩節車(chē)廂在北部郊區,是日本最新的筆試在對抗全球變暖。
70 、1. All entries submitted must be original. The entrant must abide by terms and conditions set by the Organizer.───任何申請如未能符合本屆影視獎所列條款及細則,主辦機構均有權拒絕接受。
71 、The 1968 Games also saw the first drug disqualification, as a Swedish entrant in the modern pentathlon, Hans-Gunnar, tested positive for excessive alcohol.───在參加現代五項比賽項目的瑞典隊中.有一名運動(dòng)員漢斯岡納在檢查中被發(fā)現酒精含量過(guò)高。
72 、By pitching its vision of an Olympic Games along Lake Michigan and backing it with a solid financial plan, Chicago prevailed over Los Angeles yesterday to become the U.S. entrant in the international competition for the 2016 Summer Games.───由于描繪了一幅密歇根湖上辦奧運的美好前景,而且有強大的財政計劃支持,昨天芝加哥壓倒洛杉磯成為2016年奧運會(huì )的國際競爭中美國參選城市。
73 、The entrant may invest in commercial, industrial or residential properties, including land and pre-completion properties in Hong Kong.───投資者可投資于本港的商用、工業(yè)或住宅物業(yè),包括土地和樓花。
74 、unauthorized entrant───未獲授權進(jìn)境者;擅自入境者
75 、Each entrant agrees to be bound by the provisions of this announcement, by the regulations of his/ her licensing authority and by the decisions of the ARRL Awards Committee, acting for the IARU International Secretariat.───參賽者必須同意遵守前述的比賽規則、己執照所規範的事項、ARRL獎狀委員會(huì )因應IARU國際秘書(shū)處的要求所做的決定。
76 、Each entrant may submit only one entry form.───每位參加者只可遞交一份參加表格。
77 、The new GT Due from WRC in Italy is the latest entrant into this class and its a pretty solid looking car.───新的燃氣輪機由于來(lái)自世界無(wú)線(xiàn)電通信在意大利是最新進(jìn)入這個(gè)階級及其相當堅實(shí)的賽車(chē)。
78 、The commissioned entrant should provide and install all effect lighting, if necessary, within the proposed sculpture.───如有需要,獲委約者可自行提供及安裝特別燈光效果。
79 、In the event of any disputes, the Organizing Committee reserves the right to disqualify any entry and/or retract any award from the entrant.───如出現任何爭議,主辦機構對有關(guān)作品的參賽資格或頒發(fā)的獎項保留撤消或收回之權利。
80 、Image files will not be returned. Notification will be sent by email (if provided by entrant) or by airmail.───數碼影像組數碼影像組數碼影像組數碼影像組比賽規則比賽規則比賽規則比賽規則::::
81 、an entrant to the diplomatic service───初入外交界做事的人
82 、Stanford's entrant "Junior" is a converted 2006 Volkswagen Passat whose steering, throttle and brakes all have been modified by engineers to be completely computer-controllable.───“但是新一代汽車(chē)必須能夠應付周遭變化。機器人必須能識別其他車(chē)輛,理解對方也在運行中并在靠近時(shí)有所反應?!?/p>
83 、BYD is a global leader in rechargeable battery technology, but only a recent entrant to the Chinese car industry.───比亞迪在充電電池技術(shù)方面位居全球領(lǐng)先地位,但在中國汽車(chē)業(yè)卻是個(gè)新面孔。
什么是條件鎖,讀寫(xiě)鎖,自旋鎖,可重入鎖?
自旋鎖:當進(jìn)程進(jìn)入CPU運行時(shí),就會(huì )給它的代碼上鎖,以免別的CPU中的進(jìn)程修改里面的代碼(不排除CPU給別的CPU上鎖這樣的情況,以后會(huì )討論到。)。所謂子旋鎖就是這樣的一把鎖:進(jìn)程A進(jìn)入CPU,鎖上門(mén)運行,進(jìn)程B來(lái)到CPU前,發(fā)現門(mén)被鎖上了,于是等待進(jìn)程A出來(lái)交出開(kāi)鎖鑰匙。
什么是條件鎖,讀寫(xiě)鎖,自旋鎖,可重入鎖?
展開(kāi)全部
自旋鎖(Spin lock)
自旋鎖與互斥鎖有點(diǎn)類(lèi)似,只是自旋鎖不會(huì )引起調用者睡眠,如果自旋鎖已經(jīng)被別的執行單元保持,調用者就一直循環(huán)在那里看是
否該自旋鎖的保持者已經(jīng)釋放了鎖,"自旋"一詞就是因此而得名。其作用是為了解決某項資源的互斥使用。因為自旋鎖不會(huì )引起調用者睡眠,所以自旋鎖的效率遠
高于互斥鎖。雖然它的效率比互斥鎖高,但是它也有些不足之處:
1、自旋鎖一直占用CPU,他在未獲得鎖的情況下,一直運行--自旋,所以占用著(zhù)CPU,如果不能在很短的時(shí) 間內獲得鎖,這無(wú)疑會(huì )使CPU效率降低。
2、在用自旋鎖時(shí)有可能造成死鎖,當遞歸調用時(shí)有可能造成死鎖,調用有些其他函數也可能造成死鎖,如 copy_to_user()、copy_from_user()、kmalloc()等。
因此我們要慎重使用自旋鎖,自旋鎖只有在內核可搶占式或SMP的情況下才真正需要,在單CPU且不可搶占式的內核下,自旋鎖的操作為空操作。自旋鎖適用于鎖使用者保持鎖時(shí)間比較短的情況下。
兩種鎖的加鎖原理
互斥鎖:線(xiàn)程會(huì )從sleep(加鎖)——>running(解鎖),過(guò)程中有上下文的切換,cpu的搶占,信號的發(fā)送等開(kāi)銷(xiāo)。
自旋鎖:線(xiàn)程一直是running(加鎖——>解鎖),死循環(huán)檢測鎖的標志位,機制不復雜。
互斥鎖屬于sleep-waiting類(lèi)型的鎖。例如在一個(gè)雙核的機器上有兩個(gè)線(xiàn)程(線(xiàn)程A和線(xiàn)程B),它們分別運行在Core0和
Core1上。假設線(xiàn)程A想要通過(guò)pthread_mutex_lock操作去得到一個(gè)臨界區的鎖,而此時(shí)這個(gè)鎖正被線(xiàn)程B所持有,那么線(xiàn)程A就會(huì )被阻塞
(blocking),Core0 會(huì )在此時(shí)進(jìn)行上下文切換(Context
Switch)將線(xiàn)程A置于等待隊列中,此時(shí)Core0就可以運行其他的任務(wù)(例如另一個(gè)線(xiàn)程C)而不必進(jìn)行忙等待。而自旋鎖則不然,它屬于busy-waiting類(lèi)型的鎖,如果線(xiàn)程A是使用pthread_spin_lock操作去請求鎖,那么線(xiàn)程A就會(huì )一直在
Core0上進(jìn)行忙等待并不停的進(jìn)行鎖請求,直到得到這個(gè)鎖為止。
兩種鎖的區別
互斥鎖的起始原始開(kāi)銷(xiāo)要高于自旋鎖,但是基本是一勞永逸,臨界區持鎖時(shí)間的大小并不會(huì )對互斥鎖的開(kāi)銷(xiāo)造成影響,而自旋鎖是死循環(huán)檢測,加鎖全程消耗cpu,起始開(kāi)銷(xiāo)雖然低于互斥鎖,但是隨著(zhù)持鎖時(shí)間,加鎖的開(kāi)銷(xiāo)是線(xiàn)性增長(cháng)。
兩種鎖的應用
互斥鎖用于臨界區持鎖時(shí)間比較長(cháng)的操作,比如下面這些情況都可以考慮
1 臨界區有IO操作
2 臨界區代碼復雜或者循環(huán)量大
3 臨界區競爭非常激烈
4 單核處理器
至于自旋鎖就主要用在臨界區持鎖時(shí)間非常短且CPU資源不緊張的情況下,自旋鎖一般用于多核的服務(wù)器。
lock與Syntronized的區別
轉自自:
java并發(fā)之Lock與synchronized的區別
1)Lock是一個(gè)接口,而synchronized是Java中的關(guān)鍵字,synchronized是內置的語(yǔ)言實(shí)現;
2)synchronized在發(fā)生異常時(shí),會(huì )自動(dòng)釋放線(xiàn)程占有的鎖,因此不會(huì )導致死鎖現象發(fā)生;而Lock在發(fā)生異常時(shí),如果沒(méi)有主動(dòng)通過(guò)unLock()去釋放鎖,則很可能造成死鎖現象,因此使用Lock時(shí)需要在finally塊中釋放鎖;
3)Lock可以讓等待鎖的線(xiàn)程響應中斷,而synchronized卻不行,使用synchronized時(shí),等待的線(xiàn)程會(huì )一直等待下去,不能夠響應中斷;
4)通過(guò)Lock可以知道有沒(méi)有成功獲取鎖,而synchronized卻無(wú)法辦到。
5)Lock可以提高多個(gè)線(xiàn)程進(jìn)行讀操作的效率。
在性能上來(lái)說(shuō),如果競爭資源不激烈,兩者的性能是差不多的,而當競爭資源非常激烈時(shí)(即有大量線(xiàn)程同時(shí)競爭),此時(shí)Lock的性能要遠遠優(yōu)于synchronized。所以說(shuō),在具體使用時(shí)要根據適當情況選擇。
兩者在鎖的相關(guān)概念上區別:
1.可重入鎖
如果鎖具備可重入性,則稱(chēng)作為可重入鎖。像synchronized和ReentrantLock都是可重入鎖,可重入性在我看來(lái)實(shí)際上表明了鎖的分配機制:基于線(xiàn)程的分配,而不是基于方法調用的分配。舉個(gè)簡(jiǎn)單的例子,當一個(gè)線(xiàn)程執行到某個(gè)synchronized方法時(shí),比如說(shuō)method1,而在method1中會(huì )調用另外一個(gè)synchronized方法method2,此時(shí)線(xiàn)程不必重新去申請鎖,而是可以直接執行方法method2。
看下面這段代碼就明白了:
{$i}
{$i}
{$i}
{$i}
{$i}
{$i}
{$i}
{$i}
{$i}
class MyClass
{
public synchronized void method1()
{
method2();
}
public synchronized void method2()
{
}
}
上述代碼中的兩個(gè)方法method1和method2都用synchronized修飾了,假如某一時(shí)刻,線(xiàn)程A執行到了method1,此時(shí)線(xiàn)程A獲取了這個(gè)對象的鎖,而由于method2也是synchronized方法,假如synchronized不具備可重入性,此時(shí)線(xiàn)程A需要重新申請鎖。但是這就會(huì )造成一個(gè)問(wèn)題,因為線(xiàn)程A已經(jīng)持有了該對象的鎖,而又在申請獲取該對象的鎖,這樣就會(huì )線(xiàn)程A一直等待永遠不會(huì )獲取到的鎖。
而由于synchronized和Lock都具備可重入性,所以不會(huì )發(fā)生上述現象。
2.可中斷鎖
可中斷鎖:顧名思義,就是可以相應中斷的鎖。
在Java中,synchronized就不是可中斷鎖,而Lock是可中斷鎖。
如果某一線(xiàn)程A正在執行鎖中的代碼,另一線(xiàn)程B正在等待獲取該鎖,可能由于等待時(shí)間過(guò)長(cháng),線(xiàn)程B不想等待了,想先處理其他事情,我們可以讓它中斷自己或者在別的線(xiàn)程中中斷它,這種就是可中斷鎖。
在前面演示lockInterruptibly()的用法時(shí)已經(jīng)體現了Lock的可中斷性。
3.公平鎖
公平鎖即盡量以請求鎖的順序來(lái)獲取鎖。比如同是有多個(gè)線(xiàn)程在等待一個(gè)鎖,當這個(gè)鎖被釋放時(shí),等待時(shí)間最久的線(xiàn)程(最先請求的線(xiàn)程)會(huì )獲得該所,這種就是公平鎖。
非公平鎖即無(wú)法保證鎖的獲取是按照請求鎖的順序進(jìn)行的。這樣就可能導致某個(gè)或者一些線(xiàn)程永遠獲取不到鎖。
在Java中,synchronized就是非公平鎖,它無(wú)法保證等待的線(xiàn)程獲取鎖的順序。
而對于ReentrantLock和ReentrantReadWriteLock,它默認情況下是非公平鎖,但是可以設置為公平鎖。
看一下這2個(gè)類(lèi)的源代碼就清楚了:
在ReentrantLock中定義了2個(gè)靜態(tài)內部類(lèi),一個(gè)是NotFairSync,一個(gè)是FairSync,分別用來(lái)實(shí)現非公平鎖和公平鎖。
我們可以在創(chuàng )建ReentrantLock對象時(shí),通過(guò)以下方式來(lái)設置鎖的公平性:
{$i}
ReentrantLock
lock = new ReentrantLock(true);
如果參數為true表示為公平鎖,為fasle為非公平鎖。默認情況下,如果使用無(wú)參構造器,則是非公平鎖。
另外在ReentrantLock類(lèi)中定義了很多方法,比如:
isFair() //判斷鎖是否是公平鎖
isLocked() //判斷鎖是否被任何線(xiàn)程獲取了
isHeldByCurrentThread() //判斷鎖是否被當前線(xiàn)程獲取了
hasQueuedThreads() //判斷是否有線(xiàn)程在等待該鎖
在ReentrantReadWriteLock中也有類(lèi)似的方法,同樣也可以設置為公平鎖和非公平鎖。不過(guò)要記住,ReentrantReadWriteLock并未實(shí)現Lock接口,它實(shí)現的是ReadWriteLock接口。
4.讀寫(xiě)鎖
讀寫(xiě)鎖將對一個(gè)資源(比如文件)的訪(fǎng)問(wèn)分成了2個(gè)鎖,一個(gè)讀鎖和一個(gè)寫(xiě)鎖。
正因為有了讀寫(xiě)鎖,才使得多個(gè)線(xiàn)程之間的讀操作不會(huì )發(fā)生沖突。
ReadWriteLock就是讀寫(xiě)鎖,它是一個(gè)接口,ReentrantReadWriteLock實(shí)現了這個(gè)接口。
可以通過(guò)readLock()獲取讀鎖,通過(guò)writeLock()獲取寫(xiě)鎖。
性能比較
在JDK1.5中,synchronized是性能低效的。因為這是一個(gè)重量級操作,它對性能最大的影響是阻塞的是實(shí)現,掛起線(xiàn)程和恢復線(xiàn)程的操作都需要轉入內核態(tài)中完成,這些操作給系統的并發(fā)性帶來(lái)了很大的壓力。相比之下使用Java提供的Lock對象,性能更高一些。Brian
Goetz對這兩種鎖在JDK1.5、單核處理器及雙Xeon處理器環(huán)境下做了一組吞吐量對比的實(shí)驗,發(fā)現多線(xiàn)程環(huán)境下,synchronized的吞吐量下降的非常嚴重,而ReentrankLock則能基本保持在同一個(gè)比較穩定的水平上。但與其說(shuō)ReetrantLock性能好,倒不如說(shuō)synchronized還有非常大的優(yōu)化余地,于是到了JDK1.6,發(fā)生了變化,對synchronize加入了很多優(yōu)化措施,有自適應自旋,鎖消除,鎖粗化,輕量級鎖,偏向鎖等等。導致在JDK1.6上synchronize的性能并不比Lock差。官方也表示,他們也更支持synchronize,在未來(lái)的版本中還有優(yōu)化余地,所以還是提倡在synchronized能實(shí)現需求的情況下,優(yōu)先考慮使用synchronized來(lái)進(jìn)行同步。
版權聲明: 本站僅提供信息存儲空間服務(wù),旨在傳遞更多信息,不擁有所有權,不承擔相關(guān)法律責任,不代表本網(wǎng)贊同其觀(guān)點(diǎn)和對其真實(shí)性負責。如因作品內容、版權和其它問(wèn)題需要同本網(wǎng)聯(lián)系的,請發(fā)送郵件至 舉報,一經(jīng)查實(shí),本站將立刻刪除。