|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
你精通任何一门语言就最强大。现在来看,java的市场比C#大,C#容易入手,比较简单,java比较难1.java.io效力低的缘故原由
Butinmostcases,JavaapplicationshavenottrulybeenI/Oboundinthesensethattheoperatingsystemcouldntshuttledatafastenoughtokeepthembusy.Instead,theJVMshavenotbeendoingI/Oefficiently.TheresanimpedancemismatchbetweentheoperatingsystemandtheJavastream-basedI/Omodel.Theoperatingsystemwantstomovedatainlargechunks(buffers),oftenwiththeassistanceofhardwareDirectMemoryAccess(DMA).TheI/OclassesoftheJVMliketooperateonsmallpieces―singlebytes,orlinesoftext.Thismeansthattheoperatingsystemdeliversbuffersfullof
datathatthestreamclassesofjava.iospendalotoftimebreakingdownintolittlepieces,oftencopyingeachpiecebetweenseverallayersofobjects.Theoperatingsystemwantstodeliverdatabythetruckload.Thejava.ioclasseswanttoprocessdatabytheshovelful.NIOmakesiteasiertobackthetruckrightuptowhereyoucanmakedirectuseofthedata(aByteBufferobject).
2.NIO中的办理计划概略
Thejava.niopackageprovidesnewabstractionstoaddressthisproblem.TheChannelandSelectorclassesinparticularprovidegenericAPIstoI/OservicesthatwerenotreachablepriortoJDK1.4.TheTANSTAAFLprinciplestillapplies:youwontbeabletoaccesseveryfeatureofeveryoperatingsystem,butthesenewclassesprovideapowerfulnewframeworkthatencompassesthehigh-performanceI/Ofeaturescommonlyavailableoncommercialoperatingsystemstoday.Additionally,anewServiceProviderInterface(SPI)isprovidedinjava.nio.channels.spithatallowsyoutopluginnewtypesofchannelsandselectorswithoutviolatingcompliancewiththespecifications.
TANSTAAFLprinciple-----------ThereAintNoSuchThingAsAFreeLunch.
3.FileIO
Inolderoperatingsystems,thisusuallymeantissuingacommanddirectlytothediskdrivertoreadtheneededdisksectors.Butinmodern,pagedoperatingsystems,thefilesystemtakesadvantageofdemandpagingtobringdataintomemory.
3.1FileLocking
Whilethename"filelocking"implieslockinganentirefile(andthatisoftendone),lockingisusuallyavailableatafiner-grainedlevel.Fileregionsareusuallylocked,withgranularitydowntothebytelevel.Locksareassociatedwithaparticularfile,beginningataspecificbytelocationwithinthatfileandrunningforaspecificrangeofbytes.Thisis
importantbecauseitallowsmanyprocessestocoordinateaccesstospecificareasofafilewithoutimpedingotherprocessesworkingelsewhereinthefile.
Filelocksareeitheradvisoryormandatory.TheformerisusedintheMostUnixandUnixlikeSystem,whilethelatterisusedintheMicrosoftOperatingSystem.
手机用到的是用j2me所编出来的小程序。 |
|