资源描述:
《java concurrency in practice, by brian goetz et al, addison wesley, may 2006外语英文电子书》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、JavaConcurrencyinPracticeByBrianGoetz,TimPeierls,JoshuaBloch,JosephBowbeer,DavidHolmes,DougLea...............................................Publisher:AddisonWesleyProfessionalPubDate:May09,2006PrintISBN-10:0-321-34960-1PrintISBN-13:978-0-321-34960-6Pages:384Chapter1.IntroductionWritingcorrectprogr
2、amsishard;writingcorrectconcurrentprogramsisharder.Therearesimplymorethingsthatcangowronginaconcurrentprogramthaninasequentialone.So,whydowebotherwithconcurrency?ThreadsareaninescapablefeatureoftheJavalanguage,andtheycansimplifythedevelopmentofcomplexsystemsbyturningcomplicatedasynchronouscodeintos
3、implerstraight-linecode.Inaddition,threadsaretheeasiestwaytotapthecomputingpowerofmultiprocessorsystems.And,asprocessorcountsincrease,exploitingconcurrencyeffectivelywillonlybecomemoreimportant.1.1.A(Very)BriefHistoryofConcurrencyIntheancientpast,computersdidn'thaveoperatingsystems;theyexecutedasin
4、gleprogramfrombeginningtoend,andthatprogramhaddirectaccesstoalltheresourcesofthemachine.Notonlywasitdifficulttowriteprogramsthatranonthebaremetal,butrunningonlyasingleprogramatatimewasaninefficientuseofexpensiveandscarcecomputerresources.Operatingsystemsevolvedtoallowmorethanoneprogramtorunatonce,r
5、unningindividualprogramsinprocesses:isolated,independentlyexecutingprogramstowhichtheoperatingsystemallocatesresourcessuchasmemory,filehandles,andsecuritycredentials.Iftheyneededto,processescouldcommunicatewithoneanotherthroughavarietyofcoarse-grainedcommunicationmechanisms:sockets,signalhandlers,s
6、haredmemory,semaphores,andfiles.Severalmotivatingfactorsledtothedevelopmentofoperatingsystemsthatallowedmultipleprogramstoexecutesimultaneously:Resourceutilization.Programssometimeshavetowaitforexternaloperationssuchasinputoroutput,andwhilewaitingcandonousefulwork.Itismoreefficienttousethatwaittime
7、toletanotherprogramrun.Fairness.Multipleusersandprogramsmayhaveequalclaimsonthemachine'sresources.Itispreferabletoletthemsharethecomputerviafiner-grainedtimeslicingthantoletoneprogramruntocompletionandthens