欢迎来到天天文库
浏览记录
ID:34556534
大小:3.08 MB
页数:64页
时间:2019-03-07
《Models for Concurrent Programming .pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、ModelsforConcurrentProgrammingtobias@neotechnology.comTobiasIvarssontwitter:@thobeweb:http://thobe.org/http://neo4j.org/hacker@NeoTechnologyCommonmisconceptions2Morethreads==Morethroughput3Finitenumberofcores4Otherlimitingfactorsf.ex.I/Oisonlyonepipe5Lockingalwaysimpe
2、desperformance6Concurrencyonthetrack,onlyoneinthestation7Amdahl’slaw1Speedup≤1-FF+NN:NumberofprocessorsF:Serialfraction8ThroughputwithThroughput:3synchronizedregions9ThroughputwithThroughput:6synchronizedregionswait...9ThroughputwithsynchronizedThroughput:9regionswait
3、...wait...9ThroughputwithsynchronizedThroughput:11regionswait...wait...wait...9ThroughputwithsynchronizedThroughput:11regionswait...wait...wait...wait...wait...wait...wait...wait...wait...wait...wait...10ThroughputwithsynchronizedregionsThroughput:11wait...wait...wait
4、...wait...wait...wait...wait...11Thefundamentals๏Threads๏Mutualexclusionsynchronizationandlocks๏JavaMemoryModelread/writebarriers&publication12TheJavaMemoryModelWhatyouneedtoknowJSR133๏Visibility/Publicationofobjects/fields๏(Un)Acceptableout-of-orderbehaviori.e.guarant
5、eesaboutordering๏ImplementationsbasedonthehardwareMMofthetargetplatform13Concurrencyabstractions14Javaasweknowit15Threads๏AbstractthelineofexcutionfromtheCPU(s)๏Providedbymost(allmainstream)operatingsystems๏CPUexecutioncancontinueonanotherthreadifonethreadblocks๏Incre
6、asesCPUutilization16Monitorssynchronized(someMonitor){readbarrier//singlethreadedregion}writebarrier17Volatileread/write18classThing{volatileStringname;StringgetName(){returnthis.name;readbarrier}voidsetName(StringnewName){this.name=newName;writebarrier}}๏Guaranteesvi
7、sibility:alwaysreadthelatestvalue๏Guaranteessafepublication:nore-orderingofpre-writeopswithpost-writeops19Monitorssynchronized(someMonitor){readbarrier//singlethreadedregion}writebarrier๏Writesmaynotbereorderedacrosstheend๏Readsmaynotbereorderedacrossthestart20java.ut
8、il.concurrent21ConcurrentMapmap=newConcurrentHashMap();๏AddsatomicoperationstotheMapinterface:-putIfAbsent(key
此文档下载收益归作者所有