Java 性能优化技巧集锦


w . d o c u - t r a c k.com w w PDF-X C hange Click to buy NOW! ᔧϔϾ㉏Ң঺ϔϾ㉏⌒⫳ᯊˈ䖭ϔ⚍ᇸ݊ᑨ䆹⊼ᛣˈ಴Ў⫼new݇䬂䆡߯ᓎϔϾᇍ䈵ᯊˈᵘ䗴ߑ᭄䫒 ᭈ᭄ব䞣(byteǃshortǃintǃlong)䆒㕂៤ˈfloat੠doubleব䞣䆒㕂៤0.0ˈ䘏䕥ؐ䆒㕂៤falseDŽ ϟˈ䇗⫼㉏ⱘᵘ䗴ߑ᭄ᯊˈ JavaӮᡞব䞣߱ྟ࣪៤⹂ᅮⱘؐ˖᠔᳝ⱘᇍ䈵㹿䆒㕂៤nullˈމ 咬䅸ᚙ 1.4 ϡ㽕䞡໡߱ྟ࣪ব䞣 ᓖᐌা㛑⫼Ѣ䫭䇃໘⧚ˈϡᑨ䆹⫼ᴹ᥻ࠊ⿟ᑣ⌕⿟DŽ া㽕᳝ᓖᐌ㹿ᡯߎˈVMህᖙ乏䇗ᭈ䇗⫼ේᷜˈ಴Ў೼໘⧚䖛⿟Ё߯ᓎњϔϾᮄⱘᇍ䈵DŽ fillInStackTrace()ⱘᴀഄ(Native)ᮍ⊩ˈfillInStackTrace()ᮍ⊩Ẕᶹේᷜˈᬊ䲚䇗⫼䎳䏾ֵᙃDŽ 㽕߯ᓎϔϾᮄⱘᇍ䈵DŽThrowable᥹ষⱘᵘ䗴ߑ᭄䇗⫼ৡЎܜ ᓖᐌᇍᗻ㛑ϡ߽DŽᡯߎᓖᐌ佪 1.3 ᜢ⫼ᓖᐌ ᣕ䴲䰏าI/Oⱘ䕃ӊࣙDŽ JDK 1.4ᓩܹњ䴲䰏าⱘI/Oᑧ(java.nio)DŽབᵰᑨ⫼㽕∖Փ⫼⠜ᴀ䕗ᮽⱘJDKˈ೼䖭䞠᳝ϔϾᬃ ᳡ࡵ఼ǃ᡹Ӌ੠ᢡपᑨ⫼ㄝDŽ✊㗠ˈ߯ᓎJava㒓⿟䳔㽕Ⳍᔧৃ㾖ⱘᓔ䫔DŽ DŽ䖭⾡ᡔᴃৃҹ೼䆌໮ᖙ乏ᬃᣕᑊথI/O⌕ⱘᑨ⫼Ё㾕ࠄˈབWeb ∴ކϟˈӮՓ⫼ϔϾ㓧މ䕗དⱘᚙ ೼ I/O䰏าˈϔѯᑨ⫼䞛⫼њ߯ᓎ໻䞣㒓⿟ⱘࡲ⊩ܡ ⠜ᴀ䕗ԢⱘJDKϡᬃᣕ䴲䰏าI/O APIDŽЎ䙓 1.2 Փ⫼䴲䰏าI/O  Ϟ䴶ⱘᗱ䏃ᇍѢ᭄㒘໘⧚ৠḋᕜ᳝⫼DŽ } return (Credit) BaseCredit.clone(); { public static Credit getNewCredit() private static Credit BaseCredit = new Credit(); ᬍ䖯ৢⱘҷⷕՓ⫼clone()ᮍ⊩ˈབϟ᠔⼎˖ } return new Credit(); { public static Credit getNewCredit() ߯ᓎᮄⱘᇍ䈵ᅲ՟䴲ᐌㅔऩDŽ՟བˈϟ䴶ᰃFactory῵ᓣⱘϔϾ݌ൟᅲ⦄˖ ೼Փ⫼䆒䅵῵ᓣ(Design Pattern)ⱘഎড়ˈབᵰ⫼Factory῵ᓣ߯ᓎᇍ䈵ˈ߭ᬍ⫼clone()ᮍ⊩ ᅲ⦄њCloneable᥹ষˈ៥Ӏৃҹ䇗⫼ᅗⱘclone()ᮍ⊩DŽclone()ᮍ⊩ϡӮ䇗⫼ӏԩ㉏ᵘ䗴ߑ᭄DŽ ⫼new݇䬂䆡߯ᓎ㉏ⱘᅲ՟ᯊˈᵘ䗴ߑ᭄䫒Ёⱘ᠔᳝ᵘ䗴ߑ᭄䛑Ӯ㹿㞾ࡼ䇗⫼DŽԚབᵰϔϾᇍ䈵 1.1 ϡ⫼new݇䬂䆡߯ᓎ㉏ⱘᅲ՟ “䗮⫼㆛”䅼䆎ⱘ䯂乬䗖ড়Ѣ໻໮᭄Javaᑨ⫼DŽ ϔǃ䗮⫼㆛  w . d o c u - t r a c k.com w w PDF-X C hange Click to buy NOW! ᭈϾ㒧ᵰ义䴶DŽᇍѢ䌁⠽㇂ǃⳂᔩҹঞ䮼᠋㔥キⱘކ㦋ᇍᣛᅮURLⱘ䇋∖ˈᑊ㓧ᤩކᠻ㸠DŽ义䴶㑻㓧 ПЁˈ߭⫳៤䆹⠛ᮁⱘҷⷕህϡ⫼ݡކᭈϾ义䴶DŽᔧJSP义䴶ᠻ㸠ᯊˈབᵰⳂᷛ⠛ᮁᏆ㒣೼㓧ކ໳㓧 义䴶⠛ᮁˈг㛑ކᷛ䆄᮶㛑໳㓧ކᬃᣕ䖭Ͼࡳ㛑ˈOpen SymphonyᎹ⿟гৠḋᬃᣕ䖭Ͼࡳ㛑DŽJSP㓧 ᷛ䆄ࡳ㛑DŽ՟བˈBEAⱘWebLogic ServerҢ6.0⠜ᴀᓔྟކ ϔѯᑨ⫼᳡ࡵ఼ࡴܹњ䴶৥JSPⱘ㓧 ᷛ䆄ކ 2.1 Փ⫼㓧 JDBCⱘᑨ⫼DŽ ࠡ䴶ҟ㒡ⱘᬍ୘ᗻ㛑ᡔᎻ䗖ড়Ѣ໻໮᭄Javaᑨ⫼ˈ᥹ϟᴹ㽕䅼䆎ⱘ䯂乬䗖ড়ѢՓ⫼JSPǃEJB៪ ѠǃJ2EE㆛ 㾷ˈ᠔ҹ᳔དࡴϞϔѯ⊼䞞DŽ ᑨഄˈে⿏ԡ᪡԰ⳌᔧѢ䰸ҹDŽؐᕫϔᦤⱘᰃˈ㱑✊⿏ԡ᪡԰䗳ᑺᖿˈԚৃ㛑Փҷⷕ↨䕗䲒Ѣ⧚ Ьҹⱘ᪡԰ˈ㗠ᰃᬍ⫼ㄝӋⱘᎺ⿏ԡ᪡԰ˈ↣Ꮊ⿏ԡⳌᔧѢЬҹDŽⳌخ ׂᬍৢⱘҷⷕϡݡ } myResult = val << 1; alterX = val << 3; { for (val = 0; val < 100000; val += 5) ⫼⿏ԡ᪡԰᳓ҷЬ⊩᪡԰ৃҹᵕ໻ഄᦤ催ᗻ㛑DŽϟ䴶ᰃׂᬍৢⱘҷⷕ˖ } myResult = val * 2; alterX = val * 8; { for (val = 0; val < 100000; val +=5) 㗗㰥ϟ䴶ⱘҷⷕ˖ 1.7 Ь⊩੠䰸⊩ ሔ䚼ব䞣䖬ৃ㛑ᕫࠄ䖯ϔℹӬ࣪DŽ䇋খ㾕ljሑৃ㛑Փ⫼ේᷜব䞣NJDŽ 䞣ˈབ䴭ᗕব䞣ǃᅲ՟ব䞣ㄝˈ䛑೼ේ(Heap)Ё߯ᓎˈ䗳ᑺ䕗᜶DŽ঺໪ˈձ䌪Ѣ݋ԧⱘ㓪䆥఼/JVMˈ 䇗⫼ᮍ⊩ᯊӴ䗦ⱘখ᭄ҹঞ೼䇗⫼Ё߯ᓎⱘЈᯊব䞣䛑ֱᄬ೼ᷜ(Stack)Ёˈ䗳ᑺ䕗ᖿDŽ݊Ҫব 1.6 ሑ䞣Փ⫼ሔ䚼ব䞣 䖭੠݋ԧⱘ㓪䆥఼ᅲ⦄᳝݇ DŽℸВ㛑໳Փᗻ㛑ᑇഛᦤ催50%DŽ (inline)᠔᳝ⱘfinalᮍ⊩ ঺໪ˈབᵰᣛᅮϔϾ㉏Ўfinalˈ߭䆹㉏᠔᳝ⱘᮍ⊩䛑ᰃfinalDŽJava㓪䆥఼ӮᇏᡒᴎӮݙ㘨 java.lang.StringDŽЎString㉏ᣛᅮfinal䰆ℶњҎӀ㽚Ⲫlength()ᮍ⊩DŽ ᏺ᳝finalׂ佄ヺⱘ㉏ᰃϡৃ⌒⫳ⱘDŽ೼JavaḌᖗAPIЁˈ᳝䆌໮ᑨ⫼finalⱘ՟ᄤˈ՟བ 1.5 ሑ䞣ᣛᅮ㉏ⱘfinalׂ佄ヺ Ёⱘ᠔᳝ᵘ䗴ߑ᭄䛑Ӯ㹿㞾ࡼ䇗⫼DŽ w . d o c u - t r a c k.com w w PDF-X C hange Click to buy NOW! PayBean bean = (PayBean) javax.rmi.PortableRemoteObject.narrow (home.create(), ("PayBeanHome"), PayBeanHome.class); PayBeanHome home = (PayBeanHome) javax.rmi.PortableRemoteObject.narrow (ctx.lookup 䖰⿟䇗⫼ⱘᓔ䫔DŽ䇋㗗㰥ϟ䴶ⱘҷⷕDŽܡ ᴀഄ᥹ষᰃEJB 2.0㾘㣗ᮄ๲ⱘݙᆍˈᅗՓᕫBean㛑໳䙓 2.6 ЎEJBᅲ⦄ᴀഄ᥹ষ EJBHomeCache㉏ϔ㠀ᑨ䆹԰Ўsingletonᅲ⦄DŽ Servletⱘinit()ᮍ⊩䞠䴶DŽབᵰᑨ⫼Ё໮໘乥㐕ഄߎ⦄EJB䆓䯂ˈ᳔ད߯ᓎϔϾEJBHomeCache㉏DŽ EJB Home᥹ষ䗮䖛JNDIৡ⿄ᶹᡒ㦋ᕫDŽ䖭Ͼ᪡԰䳔㽕Ⳍᔧৃ㾖ⱘᓔ䫔DŽJNDIᶹᡒ᳔དᬒܹ ᇍEJB Homeⱘ䆓䯂ކ 2.5 㓧 ᪡԰DŽټপ᪡԰ⱘᮍ⊩ᯊˈ䆒㕂া䇏ሲᗻ᳝߽Ѣᦤ催ᗻ㛑ˈ಴Ўᆍ఼ϡᖙݡᠻ㸠ᄬ ⱘᎹ԰াࣙ৿ᠻ㸠䇏ܗ䆌ᡞ᠔᳝getᮍ⊩䆒㕂៤“া䇏”DŽᔧᶤϾџࡵऩܕ ᅲԧBeanⱘ䚼㕆ᦣ䗄఼ 2.4 ೼䚼㕆ᦣ䗄఼Ё䆒㕂া䇏ሲᗻ ⦄Пࠡˈ㹿ᓩ⫼ⱘ义䴶᮴⊩⹂ᅮᯊˈՓ⫼includeࡼ԰ᠡড়ㅫDŽ ߎ㒧ᵰⱘ᥻ࠊ᳈ࡴ♉⌏DŽԚᯊˈা᳝ᔧ㹿ᓩ⫼ⱘݙᆍ乥㐕ഄᬍবᯊˈ៪㗙೼ᇍЏ义䴶ⱘ䇋∖≵᳝ߎ includeࡼ԰˖՟བDŽ䆹ࡼ԰ᓩܹᣛᅮ义䴶ᠻ㸠ৢ⫳៤ⱘ㒧ᵰDŽ⬅Ѣᅗ೼䖤㸠ᯊᅠ៤ˈ಴ℸᇍ䕧 ህ⹂ᅮˈ↨䖤㸠ᯊᠡ⹂ᅮ䌘⑤᳈催ᬜDŽ ೼㓪䆥Пࠡˈᏺ᳝includeᣛҸⱘ义䴶੠ᣛᅮⱘ䌘⑤㹿ড়ᑊ៤ϔϾ᭛ӊDŽ㹿ᓩ⫼ⱘ໪䚼䌘⑤೼㓪䆥ᯊ includeᣛҸ˖՟བ<%@ include file="copyright.html" %>DŽ䆹ᣛҸ೼㓪䆥ᯊᓩܹᣛᅮⱘ䌘⑤DŽ ࠡˈ೼JSP义䴶Ёᓩܹ໪䚼䌘⑤ⱘᮍ⊩Џ㽕᳝ϸ⾡˖includeᣛҸˈҹঞincludeࡼ԰DŽ ೼݌ൟⱘJSPᑨ⫼㋏㒳Ёˈ义༈ǃ义㛮䚼ߚᕔᕔ㹿ᢑপߎᴹˈ✊ৢḍ᥂䳔㽕ᓩܹ义༈ǃ义㛮DŽᔧ 2.3 䗝ᢽড়䗖ⱘᓩ⫼ᴎࠊ ᬍ៤೼Ӯ䆱BeanПݙ߽⫼JDBC䆓䯂᭄᥂ᑧৃҹᕫࠄ᳈དⱘᗻ㛑DŽ ϔѯᯊ׭ˈՓ⫼ᅲԧBeanӮᇐ㟈⿟ᑣᗻ㛑ϡՇDŽབᵰᅲԧBeanⱘଃϔ⫼䗨ህᰃᦤপ੠᳈ᮄ᭄᥂ˈ “㺙ܹ䇏প”᪡԰DŽ ӮᦤѸDŽ↣ϔϾᇍgetᮍ⊩ⱘⳈ᥹䇗⫼ѻ⫳ϔϾџࡵˈᆍ఼ᇚ೼↣ϔϾᅲԧBeanⱘџࡵПৢᠻ㸠ϔϾ ⫼Ӯ䆱Beanᇕ㺙ᇍᅲԧBeanⱘ䆓䯂㛑໳ᬍ䖯џࡵㅵ⧚ˈ಴ЎӮ䆱Beanা᳝೼ࠄ䖒џࡵ䖍⬠ᯊᠡ 䇗⫼DŽ䆓䯂ᅲԧBeanⱘӮ䆱Beanᰃᴀഄⱘˈ㛑໳ᡞ᠔᭄᳝᥂㒘㒛៤ϔϾ㒧ᵘˈ✊ৢ䖨ಲᅗⱘؐDŽ Ⳉ᥹䆓䯂ᅲԧBeanϡ߽Ѣᗻ㛑DŽᔧᅶ᠋⿟ᑣ䖰⿟䆓䯂ᅲԧBeanᯊˈ↣ϔϾgetᮍ⊩䛑ᰃϔϾ䖰⿟ 2.2 ྟ㒜䗮䖛Ӯ䆱Bean䆓䯂ᅲԧBean ᷛ䆄ᦤ催ᗻ㛑ⱘᬜᵰ↨䕗ᯢᰒ˗ডПˈᬜᵰৃ㛑⬹䗞ϔㅍDŽކ ᇍѢҷⷕ䘏䕥໡ᴖⱘ义䴶ˈ߽⫼㓧 Փ⫼DŽ 㛑໳ֱᄬ义䴶ᠻ㸠ⱘ㒧ᵰˈկৢ㒻䇋∖ކЏ义ᴹ䇈ˈ䖭Ͼࡳ㛑ᵕ᳝݊⫼DŽᇍѢ䖭㉏ᑨ⫼ˈ义䴶㑻㓧 w . d o c u - t r a c k.com w w PDF-X C hange Click to buy NOW! 2.8 ঞᯊ⏙䰸ϡݡ䳔㽕ⱘӮ䆱 } KeyValue++; public static synchronized long getKey() throws RemoteException { return private static long KeyValue = System.currentTimeMillis(); { public class keyGenerator extends UnicastRemoteObject implements Remote ՟ᄤ˖ 䗮䖛RMI⊼ݠᡞRMI䖰⿟ᇍ䈵㒥ᅮࠄJNDIᷥDŽᅶ᠋⿟ᑣ䗮䖛JNDI䖯㸠ᶹᡒDŽϟ䴶ᰃϔϾܜRMI੠JNDIDŽ 䖬᳝݊Ҫ޴⾡ࡲ⊩ˈԚ䖭ѯࡲ⊩ৠḋ䛑᳝৘㞾ⱘሔ䰤DŽԐТা᳝ϔϾㄨḜ↨䕗⧚ᛇ˖㒧ড়䖤⫼ ⱘMACഄഔ˗བᵰՓ⫼JNIˈ߭⿟ᑣህ㽕ձ䌪Ѣ⡍ᅮⱘOSDŽ 䡈Microsoftⱘᗱ䏃ˈ೼BeanЁ߯ᓎϔϾGUIDDŽ✊㗠ˈབᵰϡ∖ࡽѢJNIˈJavaϡ㛑⹂ᅮ㔥व׳ ПϞDŽ঺໪ˈᅗ䖬ᇐ㟈њ䖭ḋϔ⾡ৃ㛑ˈे೼໮CPUⱘ᳡ࡵ఼ϞˈৠϔϾ↿⾦Пݙ⫳៤њϸϾЏ䬂DŽ ߽⫼NTPП㉏ⱘᯊ䩳᳡ࡵDŽ䖭㽕∖᳝䴶৥⡍ᅮᑇৄⱘᴀഄҷⷕˈҢ㗠ᡞBean೎ᅮࠄњ⡍ᅮⱘOS ᜶DŽ ๲䞣᪡԰ DŽᅗⱘ㔎⚍ᰃ㽕∖џࡵৃІ㸠࣪ˈ㗠Ϩ䗳ᑺг䕗خ↨བ ⬅ᅲԧBean㞾Ꮕ䅵ㅫЏ䬂ؐ EJBৃ⿏ỡᗻᏂDŽ ߽⫼᭄᥂ᑧݙᓎⱘᷛ䆚ᴎࠊ(SQL ServerⱘIDENTITY៪OracleⱘSEQUENCE)DŽ䖭⾡ᮍ⊩ⱘ㔎⚍ᰃ ೼EJBПݙ⫳៤Џ䬂᳝䆌໮䗨ᕘˈϟ䴶ߚᵤњ޴⾡ᐌ㾕ⱘࡲ⊩ҹঞᅗӀⱘ⡍⚍DŽ 2.7 ⫳៤Џ䬂 བᵰBeanᅲ⦄њᴀഄ᥹ষˈ߭݊ᓩ⫼ϡৃІ㸠࣪DŽ Ϟ䖤㸠DŽ ᴀഄ᥹ষᖙ乏೼EJB䚼㕆ⱘᴎ఼ϞՓ⫼DŽㅔ㗠㿔Пˈᅶ᠋⿟ᑣ੠ᦤկ᳡ࡵⱘ㒘ӊᖙ乏೼ৠϔϾJVM ᠔᭄᳝᥂੠䖨ಲؐ䛑䗮䖛ᓩ⫼ⱘᮍᓣӴ䗦ˈ㗠ϡᰃӴ䗦ؐDŽ TransactionRolledBackLocalException੠NoSuchObjectLocalExceptionDŽ ᦤկњㄝӋⱘᴀഄᓖᐌˈབTransactionRequiredLocalExceptionǃ TransactionRequiredExceptionǃTransactionRolledBackException੠NoSuchObjectExceptionDŽEJB ᮍ⊩ϡ㛑ݡᡯߎjava.rmi.RemoteExceptionᓖᐌˈࣙᣀҢRemoteException⌒⫳ⱘᓖᐌˈ↨བ 㽕ᅲ⦄ᴀഄ᥹ষˈ៥Ӏᖙ乏԰བϟׂᬍ˖ ঞњ߯ᓎIIOP䇋∖ᑊ೼㔥㒰ϞӴ䕧䇋∖ⱘstub⿟ᑣˈᅗгᰃϔϾRMI䇗⫼DŽ ៥Ӏᅮԡ䖰⿟ᇍ䈵ˈ䖨ಲҷ⧚ᓩ⫼ˈ䖭гᰃϔϾRMI䇗⫼DŽ㄀ѠϾ䇁হ⼎㣗њབԩ߯ᓎϔϾᅲ՟ˈ⍝ ㄀ϔϾ䇁হ㸼⼎៥Ӏ㽕ᇏᡒBeanⱘHome᥹ষDŽ䖭Ͼᶹᡒ䗮䖛JNDI䖯㸠ˈᅗᰃϔϾRMI䇗⫼DŽ✊ৢˈ PayBean.class); w . d o c u - t r a c k.com w w PDF-X C hange Click to buy NOW! 2.13 JDBCϢI/O ࡼ⿟ᑣҡᮻᖙ乏ᠻ㸠䕀ᤶ䖛⿟DŽ ぎ䯈DŽ঺໪ˈབᵰ᳝݊Ҫ䴲Unicodeⱘ⿟ᑣ䆓䯂᭄᥂ᑧˈᗻ㛑䯂乬ҡᮻӮߎ⦄ˈ಴Ў䖭ᯊ᭄᥂ᑧ偅ټ 䖛⿟DŽԚᑨ䆹䆄ԣ˖བᵰ䞛⫼䖭⾡ᮍᓣˈ᭄᥂ᑧӮবᕫ᳈໻ˈ಴Ў↣ϾUnicodeᄫヺ䳔㽕Ͼᄫ㡖ᄬ Unicode(ҷⷕ义13488)DŽJavaҹUnicodeᔶᓣ໘⧚᠔᭄᳝᥂ˈ಴ℸˈ᭄᥂ᑧ偅ࡼ⿟ᑣϡᖙݡᠻ㸠䕀ᤶ 䰸њ䖭ѯᰒ㗠ᯧ㾕ⱘ䗝ᢽП໪ˈ঺ϔϾᦤ催ᗻ㛑ⱘད䗝ᢽৃ㛑ህᰃᡞ᠔᳝ⱘᄫヺ᭄᥂䛑ֱᄬЎ 㓪䆥SQL䇁হˈㄝㄝDŽܜ᥹ᠻ㸠ⱘSQLǃҢ㒧ᵰ䲚ߴ䰸໮ԭⱘ߫ǃ乘 䖛⿟੠Ⳉټ ᛇᖙԴᏆ㒣њ㾷ϔѯՓ⫼JDBCᯊᦤ催ᗻ㛑ⱘ᥾ᮑˈ↨བ߽⫼䖲᥹∴ǃℷ⹂ഄ䗝ᢽᄬ 2.12 JDBCϢUnicode ఼೼ৠϔৄᴎ఼Ϟ䖤㸠ᯊˈKeep-Aliveࡳ㛑ᇍ䌘⑤߽⫼ⱘᕅડᇸ݊さߎDŽ ᳳ䯈ˈᴀᴹৃҹ䞞ᬒⱘ䌘⑤ҡᮻ㹿ऴ⫼DŽᔧWeb᳡ࡵ఼੠ᑨ⫼᳡ࡵذৠḋᕅડњᗻ㛑ˈ಴Ў೼໘⧚᱖ Ѣ䋳ᢙ䕗䞡ⱘ㔥キᴹ䇈ˈ䖭䞠ᄬ೼঺໪ϔϾ䯂乬˖㱑✊Ўᅶ᠋ֱ⬭ᠧᓔⱘ䖲᥹᳝ϔᅮⱘད໘ˈԚᅗ Apacheˈ䛑ᬃᣕHTTP Keep-AliveDŽᇍѢᦤկ䴭ᗕݙᆍⱘ㔥キᴹ䇈ˈ䖭Ͼࡳ㛑䗮ᐌᕜ᳝⫼DŽԚᰃˈᇍ њᓎゟ៪㗙䞡ᮄᓎゟ䖲᥹DŽᏖഎϞⱘ໻䚼ߚWeb᳡ࡵ఼ˈࣙᣀiPlanetǃIIS੠ܡKeep-Aliveࡳ㛑䙓 Keep-Aliveࡳ㛑Փᅶ᠋ッࠄ᳡ࡵ఼ッⱘ䖲᥹ᣕ㓁᳝ᬜˈᔧߎ⦄ᇍ᳡ࡵ఼ⱘৢ㒻䇋∖ᯊˈ 2.11 HTTP Keep-Alive 䆌ⱘᅶ᠋䇋∖ⱘ᳔໻䯈䱨ᯊ䯈ˈҹ⾦䅵DŽܕ䆱ПࠡˈServletᆍ఼ ঺໪ˈгৃҹ⫼㓪⿟ⱘᮍᓣ䇗⫼Ӯ䆱ⱘsetMaxInactiveInterval()ᮍ⊩ˈ䆹ᮍ⊩⫼ᴹ䆒ᅮ೼԰ᑳӮ ঺໪ϔ⾡ࡲ⊩ህᰃሑᖿഄᡞӮ䆱԰ᑳDŽ໻໮᭄ᑨ⫼᳡ࡵ఼䛑᳝䆒㕂Ӯ䆱԰ᑳ䯈䱨ᯊ䯈ⱘ䗝乍DŽ Փ⫼ⱘ䌘⑤DŽ HttpSessionBindingListener᥹ষDŽ䖭ḋˈা㽕ᅲ⦄valueUnbound()ᮍ⊩ˈህৃҹᰒᓣഄ䞞ᬒBean 䖭㉏ݙᄬ䯂乬Џ㽕᳝Ѡ⾡ࡲ⊩DŽ㄀ϔ⾡ࡲ⊩ᰃˈ೼᠔᳝԰⫼㣗ೈЎӮ䆱ⱘBeanЁᅲ⦄އ 㾷 ᔦѢӏԩϔϾ݋ԧⱘ㒘ӊDŽབᵰⲥ㾚JVMⱘේぎ䯈ˈᅗⱘ㸼⦄ᰃݙᄬऴ⫼ϡℷᐌഄ໻䍋໻㨑DŽ ഄ㹿ൗഒಲᬊᴎࠊಲᬊDŽҢᗻ㛑Ϟⳟˈ݌ൟⱘ⮛⢊ᰃ⫼᠋ᛳࠄ㋏㒳਼ᳳᗻഄব᜶ˈैজϡ㛑ᡞॳ಴ 䆌໮ᓔথ㗙䱣ᛣഄᡞ໻䞣ֵᙃֱᄬࠄ⫼᠋Ӯ䆱ПЁDŽϔѯᯊ׭ˈֱᄬ೼Ӯ䆱Ёⱘᇍ䈵≵᳝ঞᯊ 2.10 ServletϢݙᄬՓ⫼ ˘%@ page session="false"%˚ Ҹ˖ ᇍѢ䙷ѯ᮴䳔䎳䏾Ӯ䆱⢊ᗕⱘ义䴶ˈ݇䯁㞾ࡼ߯ᓎⱘӮ䆱ৃҹ㡖ⳕϔѯ䌘⑤DŽՓ⫼བϟpageᣛ 2.9 ೼JSP义䴶Ё݇䯁᮴⫼ⱘӮ䆱 ೼ᑨ⫼ⱘ䗔ߎ义䴶䇗⫼DŽ ᑨᔧঞᯊ䇗⫼HttpSession.invalidate()ᮍ⊩⏙䰸Ӯ䆱DŽHttpSession.invalidate()ᮍ⊩䗮ᐌৃҹ ৃ㛑ᡯߎ“ݙᄬϡ䎇”ᓖᐌDŽ೼໻㾘῵㋏㒳ЁˈІ㸠࣪Ӯ䆱ⱘҷӋᰃᕜᯖ䌉ⱘDŽᔧӮ䆱ϡݡ䳔㽕ᯊˈ ࠄ⺕Ⲭˈ⫮㟇ټ఼гৃ㛑ḍ᥂“᳔䖥᳔乥㐕Փ⫼”(Most Recently Used)ㅫ⊩ᡞ䚼ߚϡ⌏䎗ⱘӮ䆱䕀 ࡵ఼䳔㽕ֱᄬ᳈໮Ӯ䆱ᯊˈབᵰݙᄬᆍ䞣ϡ䎇ˈ᪡԰㋏㒳Ӯᡞ䚼ߚݙᄬ᭄᥂䕀⿏ࠄ⺕Ⲭˈᑨ⫼᳡ࡵ Ўњ⏙䰸ϡݡ⌏ࡼⱘӮ䆱ˈ䆌໮ᑨ⫼᳡㹓䵿ࡴᖗ㋏ᐩኘ׎ヨ༨⋠䆱䯘?0ߚ䩳DŽᔧᑨ⫼᳡ w . d o c u - t r a c k.com w w PDF-X C hange Click to buy NOW! ℷᓣⱘApplet˖ ߯ᓎϔϾᕜᇣⱘAppletˈ䆹Applet䋳䋷೼ৢৄϟ䕑ܜ ϟ䴶៥Ӏᴹⳟⳟϔ⾡݋ԧⱘᅲ⦄ᮍ⊩DŽ佪 ϔϾAppletℷ೼ϟ䕑ⱘֵᙃ᮴⭥᳝ࡽѢ哧ࢅ⫼᠋㒻㓁ㄝᕙDŽ ϟˈᰒ⼎މAppletⱘϟ䕑ᯊ䯈䕗䭓ᯊˈӮথ⫳ҔМџᚙ˛᳔໻ⱘৃ㛑ህᰃ⫼᠋ᥝ༈⾏এDŽ೼䖭⾡ᚙ Դᰃ৺ⳟࠄ䖛Փ⫼Appletⱘ㔥キˈ⊼ᛣࠄ೼ᑨ䆹䖤㸠Appletⱘഄᮍߎ⦄њϔϾऴԡヺ˛ᔧ 3.2 ᦤ⼎Applet㺙ܹ䖯⿟ 㽕೼HTML/JSP᭛ӊЁᣛᅮJAR᭛ӊˈা䳔೼Appletᷛ䆄ЁࡴܹARCHIVE = "name.jar"ໄᯢDŽ JAR᭛ӊৃҹࣙ৿ϔϾ៪㗙໮ϾⳌ݇ⱘBeanҹঞᬃᣕ᭛ӊˈ↨བ೒ᔶǃໄ䷇ǃHTML੠݊Ҫ䌘⑤DŽ ᇥ᭛ӊԧ⿃ˈ㓽ⷁϟ䕑ᯊ䯈DŽ՟བˈᅗ᳝ࡽѢAppletᦤ催ਃࡼ䗳ᑺDŽϔϾޣ㤤ᮍᓣDŽJARḷḜ᳝ࡽѢ य़㓽ⱘ᭛ӊˈᰃথᏗJavaBean㒘ӊⱘЏ㽕ᮍᓣ੠᥼ޚ JavaḷḜ᭛ӊ(JAR᭛ӊ ᰃḍ᥂JavaBeanᷛ 3.1 ⫼JARय़㓽㉏᭛ӊ 䖭ϔ䚼ߚҟ㒡ⱘݙᆍ䗖ড়Ѣ೒ᔶ⫼᠋⬠䴶ⱘᑨ⫼(Applet੠᱂䗮ᑨ⫼ ˈ㽕⫼ࠄAWT៪SwingDŽ ϝǃGUI㆛ ㅔऩⱘࡴ䫕ᴎࠊˈ಴㗠䗳ᑺᕜᖿDŽ ᇥI/O᪡԰ˈ㗠Ϩৃҹ䞛⫼↨䕗ޣ᳝ⱘ᪡԰䛑೼ݙᄬЁ䖯㸠DŽ䖭ḋˈݙᄬ᭄᥂ᑧϡ䳔㽕໡ᴖⱘㅫ⊩ᴹ 䆌᭄᥂ЈᯊഄݭܹˈԚ䖭ѯ᭄᥂ϡᖙ∌Йഄֱᄬࠄ⺕ⲬϞˈ᠔ܕTimesTenDŽݙᄬ᭄᥂ᑧⱘߎথ⚍ᰃ ϔ⾡᳓ҷӴ㒳݇㋏᭄᥂ᑧⱘᮍḜᰃˈՓ⫼೼ݙᄬЁ䖤㸠ⱘ᭄᥂ᑧ(In-memory Database)ˈ՟བ CPUⱘЏ㽕ॳ಴DŽ ᴎࠊⱘ໡ᴖㅫ⊩ˈ㗠䖭ℷᰃ᭄᥂ᑧሖ㄀ϔোᗻ㛑⫊乜䗮ᐌᘏᰃކᷛⱘЏ㽕䗨ᕘাᰃᠻ㸠ϔ༫ᅲ⦄㓧 ᇥI/O᪡԰ˈ⡍߿ᰃᇍѢ䇏᪡԰ˈԚᅲ⦄䆹Ⳃޣ⠽⧚Ϟᡞ᭄᥂ݭܹ⺕Ⲭⱘ㛑࡯᳝݇DŽ݇㋏᭄᥂ᑧ࡯೒ ᥂ᑧᴹ䇈ˈ䖤㸠ᯊⱘ䞡㽕ॳ߭Пϔᰃ⹂ֱ᠔᳝ⱘݭܹ᪡԰〇ᅮǃৃ䴴ˈ಴㗠ˈ᠔᳝ⱘᗻ㛑䯂乬䛑Ϣ 㛑ᬒࠄ᭄᥂ᑧሖгᄬ೼䯂乬ˈϨ䯂乬ⱘḍ⑤Ϣ໻໮᭄݇㋏᭄᥂ᑧ㋏㒳ⱘԧ㋏㒧ᵘ᳝݇DŽᇍѢ݇㋏᭄ ϔѯҎᡞ䌁⠽㇂Ⳃᔩࡳ㛑䕀⿏ࠄ᭄᥂ᑧሖˈ೼ϔᅮ⿟ᑺϞᦤ催њৃԌ㓽ᗻDŽ✊㗠ˈᡞ䖭䚼ߚࡳ 䭓ࠄ䲒ҹᖡফⱘ⿟ᑺDŽ ⱘݙᄬ᭄䞣Ьҹᑊথ⫼᠋᳔໻᭄䞣ˈᅗϡҙՓ᳡ࡵ఼ӋḐᯖ䌉ˈ㗠Ϩൗഒᬊ䲚ⱘᯊ䯈䯈䱨гৃ㛑ᓊ Ёֱᄬ䖭㉏᭄᥂ᵕ໻ഄ䰤ࠊњᑨ⫼ⱘৃԌ㓽ᗻˈ಴Ў᳡ࡵ఼ᢹ᳝ⱘݙᄬ㟇ᇥᖙ乏䖒ࠄ↣ϾӮ䆱ऴ⫼ ⬅Ѣ䖭㉏᭄᥂ৃҹᣝ✻㸠߫ⱘᔶᓣ㒘㒛ˈ಴ℸˈ䆌໮ᑨ⫼߯ᓎњᑲ໻ⱘVector៪HashMapDŽ೼Ӯ䆱 䆌໮ᑨ⫼䳔㽕ҹ⫼᠋Ўऩԡ೼Ӯ䆱ᇍ䈵ЁֱᄬⳌᔧ᭄䞣ⱘ᭄᥂ˈ݌ൟⱘᑨ⫼བ䌁⠽㇂੠ⳂᔩㄝDŽ 1.14 ݙᄬ᭄᥂ᑧ ߭ഫ᪡԰ᮍᓣϡݡ᳝ᬜDŽ ೼ϔѯᚙᔶϟ䖭⾡ᡔᴃ᮴ᬜDŽ՟བˈབᵰՓ⫼ৃ⒮ࡼⱘ䆄ᔩ䲚ˈ៪㗙೼ᶹ䆶ЁᣛᅮњFOR UPDATEˈ ᇥࠄ10⃵DŽޣ㛑ᦤপࠄܼ䚼᭄᥂DŽབᵰᡞഫ໻ᇣᬍ៤512ˈ߭䇗⫼᭄᥂ᑧⱘ⃵᭄ᇚ 䆒៥Ӏ㽕䘡ग़ϔϾ5000㸠ⱘ䆄ᔩ䲚ˈJDBCᖙ乏䇗⫼᭄᥂ᑧ157⃵ᠡ؛ˈ↣⃵ᦤপ32㸠᭄᥂DŽВ՟ᴹ䇈 ϟˈJDBCމབᵰᑨ⫼⿟ᑣ䳔㽕䆓䯂ϔϾ㾘῵ᕜ໻ⱘ᭄᥂䲚ˈ߭ᑨᔧ㗗㰥Փ⫼ഫᦤপᮍᓣDŽ咬䅸ᚙ w . d o c u - t r a c k.com w w PDF-X C hange Click to buy NOW! resize(width, height); // ᡞappletResize䇗⫼Ңstub⿟ᑣӴ䗦ࠄApplet { public void appletResize(int width, int height) } validate(); // ࠋᮄሣᐩ } label.setText("ϡ㛑㺙ܹᣛᅮⱘApplet"); // ᰒ⼎䫭䇃ֵᙃ { catch (Exception ex) } largeApplet.start(); largeApplet.init(); // ᰒ⼎ℷᓣⱘApplet add(largeApplet); setLayout(new GridLayout(1, 0)); // 䆒㕂Ꮧሔ remove(label); // প⍜“䇋⿡ㄝ”ֵᙃ largeApplet.setStub(this); // 䆒㕂䆹AppletⱘStub⿟ᑣ Applet largeApplet = (Applet)largeAppletClass.newInstance(); // ߯ᓎᕙ㺙䕑Appletⱘᅲ՟ Class largeAppletClass = Class.forName(largeAppletName); // 㦋ᕫᕙ㺙䕑Appletⱘ㉏ { try { public void run() } add(label); label = new Label("䇋⿡ㄝ..." + largeAppletName); // “䇋⿡ㄝ”ᦤ⼎ֵᙃ largeAppletName = getParameter("applet"); // 㽕∖㺙䕑ⱘℷᓣApplet { public void init() Label label; String largeAppletName; { public class PreLoader extends Applet implements Runnable, AppletStub import java.awt.GridLayout; import java.awt.Graphics; import java.awt.Label; import java.applet.AppletStub; import java.applet.Applet; w . d o c u - t r a c k.com w w PDF-X C hange Click to buy NOW! 3.5 ᓊ䖳䞡⬏᪡԰ } paint(g); g.clipRect(x, y, w, h); { public void update(Graphics g) ᳈⧚ᛇⱘᮍḜᰃ˖㽚Ⲫupdate()ˈা䞡⬏ሣᐩϞথ⫳ব࣪ⱘऎඳˈབϟ᠔⼎˖ public void update(Graphics g) { paint(g);} བϟᮍᓣ㽚Ⲫupdate()ᮍ⊩˖ ೼paint()䇗⫼Пࠡⱘሣᐩ⏙䰸᪡԰ˈা䳔ᣝ✻ܡ乥㐕Փ⫼೒ᔶⱘᑨ⫼ৃ㛑ߎ⦄ᰒ⼎䮾⚕⦄䈵DŽ㽕䙓 update()ᮍ⊩ⱘ咬䅸ࡼ԰ᰃ⏙䰸ሣᐩˈ✊ৢ䇗⫼paint()ᮍ⊩DŽབᵰՓ⫼咬䅸ⱘupdate()ᮍ⊩ˈ 3.4 㽚Ⲫupdateᮍ⊩ ᠔䳔ֵᙃᏆ㒣ᕫࠄˈ䆹ᮍ⊩䖨ಲfalseDŽ ᔧ೒ᔶֵᙃৃ⫼ᯊˈimageUpdate()ᮍ⊩㹿䇗⫼DŽབᵰ䳔㽕䖯ϔℹ᳈ᮄˈ䆹ᮍ⊩䖨ಲtrue˗བᵰ } return (flags & (ALLBITS | ERROR| ABORT)) == 0; } repaint(); // ᭛ӊ≵᳝ᡒࠄˈ㗗㰥ᰒ⼎ϔϾऴԡヺ error = true; }else if (flags & (ERROR |ABORT )) != 0) { repaint(); if ((flags & ALLBITS) !=0 { { public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) imageUpdate()ˈ㛑໳⫼ϔ⃵repaint()᪡԰೼ሣᐩϞ⬏ߎ೒ᔶDŽϟ䴶ᦤկњϔϾ՟ᄤDŽ ImageObserver᥹ষৃ⫼ᴹ᥹ᬊ೒ᔶ㺙ܹⱘᦤ⼎ֵᙃDŽImageObserver᥹ষা᳝ϔϾᮍ⊩ 㺙ܹᅗܜ 3.3 ೼⬏ߎ೒ᔶПࠡ乘 resize()ᮍ⊩DŽ ϔḋⱘᮍ⊩ˈԚappletResize()ᮍ⊩䰸໪DŽ䖭䞠៥ӀᡞᇍappletResize()ᮍ⊩ⱘ䇗⫼Ӵ䗦㒭њ ਞ䆝Appletࠄા䞠ᦤপ䖭ϾֵᙃDŽ঺ϔϾؐᕫ⊼ᛣⱘഄᮍᰃˈAppletStub᥹ষࣙ৿䆌໮੠Applet㉏ AppletStub᥹ষDŽϔ㠀ഄˈAppletҢ䇗⫼㗙߸ᮁ㞾ᏅⱘcodebaseDŽ೼ᴀ՟Ёˈ៥Ӏᖙ乏䇗⫼setStub() PreLoaderᅲ⦄њˈܜ㓪䆥ৢⱘҷⷕᇣѢ2Kˈϟ䕑䗳ᑺᕜᖿDŽҷⷕЁ᳝޴Ͼഄᮍؐᕫ⊼ᛣDŽ佪 { { w . d o c u - t r a c k.com w w PDF-X C hange Click to buy NOW! if (lastOne.time != time) // ㄝᕙϞϔџӊ㒧ᴳ { synchronized(lastOne.running) } atch (Exception ex) {} 㒓⿟ذ // ᱖ } Thread.sleep(milliseconds); { try { if (milliseconds > 0) { public void run() { (new Thread() lastOne.time = time; // 㦋ᕫᔧࠡᯊ䯈 final long time = System.currentTimeMillis(); final LastOne lastOne = (LastOne) e_queue.get(token); } } e_queue.put(token, new LastOne()); { if (!e_queue.containsKey(id)) // e_queue: ᠔᳝џӊⱘ䲚ড় { synchronized(e_queue) { public static void runOnce(String id, final long milliseconds) ৢᅗৃҹ⫼ᴹ᥻ࠊᎹ԰㒓⿟DŽ 㒧”ˈ಴Ў↣⃵া㛑໘⧚ϔϾџӊDŽϟ䴶ᦤկњϔϾџӊ໘⧚ⱘㅔऩ՟ᄤˈԚ㒣䖛ᠽሩޏ“ӊৃ㛑㹿 བᵰџӊ㽕ਃࡼϔ乍㗫ᯊⱘᎹ԰ˈߚ⾏ߎϔϾᎹ԰㒓⿟ᰃϔ⾡䕗དⱘ໘⧚ᮍᓣ˗৺߭ˈϔѯ䚼 ᔧࠡџӊ䕀㗠໘⧚᳔ৢϔϾᬊࠄⱘ䞡⬏џӊ˗৺߭ˈ៥Ӏ㒻㓁䖯㸠ᔧࠡⱘ䞡⬏䖛⿟DŽ ℶ໘⧚ذ ᓎ䆂೼䖭䞠ᓩܹϔϾ᭄↿⾦ⱘᯊᏂˈेབᵰ៥Ӏゟे᥹ᬊࠄњ঺ϔϾ䞡⬏џӊˈৃҹ Ͼ䯂乬᳔དⱘࡲ⊩ᰃᗑ⬹᠔᳝“䖳ࠄ”ⱘџӊDŽ ሣᐩП㉏ⱘ᪡԰ᇐ㟈䞡⬏ሣᐩџӊ໻䞣ഄǃᖿ䗳ഄ⫳៤ˈ⫮㟇䍙䖛њⳌ݇ҷⷕⱘᠻ㸠䗳ᑺDŽᇍҬ䖭 ⫼᠋ᬍবにষ໻ᇣ៪㗙⒮ࡼϔϾにষᯊˈ䖭ϔ⚍䗮ᐌৃҹᕜᯢᰒഄ㾖ᆳࠄDŽᬍবにষ໻ᇣ៪㗙⒮ࡼ ᇍѢ೒ᔶ⫼᠋⬠䴶ⱘᑨ⫼ᴹ䇈ˈᗻ㛑ԢϟⱘЏ㽕ॳ಴ᕔᕔৃҹᔦ㒧Ў䞡⬏ሣᐩⱘᬜ⥛ԢϟDŽᔧ w . d o c u - t r a c k.com w w PDF-X C hange Click to buy NOW! ⱘᰃҔМ㉏ൟⱘ೒ᔶˈ↨བ5-ԡRGBǃ8-ԡRGBǃ♄ᑺ㑻ㄝDŽކ䆌៥Ӏᣛᅮ㽕㓧ܕ ImageType public BufferedImage (int width, int height, int imageType) 㑻೒ᔶDŽᅗⱘᵘ䗴ߑ᭄ᕜㅔऩˈབϟ᠔⼎˖ ᷙ೒ᔶ᭄᥂DŽ䖭Ͼ㉏ϔ㠀Փ⫼RGB(㑶ǃ㓓ǃ㪱 买㡆῵ൟˈԚгৃҹ໘⧚♄ᑺܝϾColorModel੠ϔ㒘 ऎDŽϔϾBufferedImageࣙ৿ϔކ BufferedImageᄤ㉏ᦣ䗄ⱘ೒ᔶᏺ᳝ϔϾৃ䆓䯂ⱘ೒ᔶ᭄᥂㓧 BufferedImageDŽ ᅲ⦄њϔ⾡ᮄⱘ೒ᔶ㉏ൟˈेޚ䖭Ͼ䯂乬㗠ᦤߎⱘJavaᷛއ೼Փ⫼䖭⾡ᡔᴃᯊᗻ㛑ϡՇDŽЎ㾷 ㋴DŽ⬅Ѣ䖭⾡ᡔᴃ㽕೼ݙᄬЁ໻䞣ഄ䖯㸠ԡ໡ࠊ᪡԰ˈᮽᳳⱘJDKڣJavaᖙ乏Ⳉ᥹໘⧚ᵘ៤᭛ᄫⱘ Java JDK 1.2Փ⫼њϔϾ䕃ᰒ⼎䆒໛ˈՓᕫ᭛ᴀ೼ϡৠⱘᑇৄϞⳟ䍋ᴹⳌԐDŽЎᅲ⦄䖭Ͼࡳ㛑ˈ 3.7 Փ⫼BufferedImage myGraphics.drawImage(myOffscreenImage, 0, 0, this); offscreenGraphics.drawImage(img, 50, 50, this); Graphics offscreenGraphics = myOffscreenImage.getGraphics(); Image myOffscreenImage = createImage(size().width, size().height); Graphics myGraphics; 㸠݊ҪӏࡵDŽϟ䴶ⱘӾҷⷕ⠛ᮁ⼎㣗њ䖭⾡ᡔᴃDŽ 㑻ⱘ㒓⿟䋳䋷⬏೒ˈՓᕫ⿟ᑣ㛑໳߽⫼ぎ䯆ⱘCPUᯊ䯈ᠻܜҹᴹಲߛᤶDŽ䖭ḋˈ៥Ӏৃҹ⫼ϔϾԢӬ ऎˈ᠔ҹ⿟ᑣৃކऎ㒬೒ˈᅠ៤ৢゟेᡞᭈϾ೒ᔶᰒ⼎ߎᴹDŽ⬅Ѣ᳝ϸϾ㓧ކ ೼ሣᐩП໪ⱘ㓧 ऎކ 3.6 Փ⫼ঠ㓧 } public Object running = new Object(); public long time=0; { private static class LastOne private static Hashtable e_queue = new Hashtable(); } }}).start(); } return; া໘⧚᳔ৢϔϾџӊ // w . d o c u - t r a c k.com w w PDF-X C hange Click to buy NOW! ᢙᖗӏԩ䋳䴶ᕅડDŽ 㟈ᗻ㛑䰡Ԣˈेᑨ⫼೼ৢৄ䖯㸠⒮ࡼ᪡԰DŽབᵰᰃ⫼᠋೼⒮ࡼϔϾᑨ⫼ˈ䙷Мᅗᘏᰃ೼ࠡৄˈ᮴䳔 ೼໻໮᭄ᑨ⫼ЁˈՓ⫼䖭⾡ᡔᴃ㛑໳ᦤ催⒮ࡼ䗳ᑺDŽা᳝೼ϔ⾡ᚙᔶϟˈWindow BlittingӮᇐ setScrollMode(int mode); ⫼Window Blittingᡔᴃˈ䆒㕂ᮍ⊩བϟ˖ ऎЁᡞ೒ᔶ⿏ࠄᮄⱘԡ㕂ˈা䞡⬏ᮄߎ⦄ⱘऎඳDŽ㽕೼Swingᑨ⫼ЁՓކBlittingᡔᴃⳈ᥹೼ሣᐩ㓧 ㋏㒳ⱘ೒ᔶᄤ㋏㒳ˈࣙᣀWIN32 GDIǃMacOS੠X/Windowsˈ䛑ᬃᣕWindow BlittingᡔᴃDŽWindow 䖯㸠⒮ࡼ᪡԰ᯊˈ᠔᳝ৃ㾕ⱘݙᆍϔ㠀䛑㽕䞡⬏ˈҢ㗠ᇐ㟈໻䞣ϡᖙ㽕ⱘ䞡⬏Ꮉ԰DŽ䆌໮᪡԰ 3.9 Փ⫼Window Blitting GraphicsConfiguration.createCompatibleVolatileImage()ᮍ⊩߯ᓎDŽ Component.createVolatileImage()៪㗙 㱑✊VolatileImageᰃϔϾᢑ䈵㉏ˈԚϡ㽕Ңᅗ䖭䞠⌒⫳ᄤ㉏DŽVolatileImageᑨ䆹䗮䖛 contentsLost()ᮍ⊩ਞ䆝៥Ӏˈ㞾Ң᳔ৢϔ⃵validate()䇗⫼Пৢˈ೒ᔶⱘݙᆍᰃ৺϶༅DŽ ↣⃵ҢVolatileImageᇍ䈵໡ࠊݙᆍ៪㗙ݭܹVolatileImageᯊˈᑨ䆹䇗⫼validate()ᮍ⊩DŽ contentsLost(); public abstract int validate(GraphicsConfiguration gc);public abstract Boolean ϸϾ㛑໳Ẕᶹݙᆍᰃ৺϶༅ⱘᮍ⊩˖ 〇ᅮⱘ(volatile)”DŽ಴ℸˈ೼Փ⫼೒ᔶПࠡˈ᳔དẔᶹϔϟᅗⱘݙᆍᰃ৺϶༅DŽVolatileImage᳝ Ѣ㋏㒳Փ⫼ⱘ೒ᔶ䗖䜡఼DŽVolatileImageⱘݙᆍ䱣ᯊৃ㛑϶༅ˈгेᅗᰃ“ϡއ㛑ⱘᬍ୘⿟ᑺЏ㽕প VolatileImageৃҹ߯ᓎ⹀ӊࡴ䗳ⱘ೒ᔶҹঞㅵ⧚೒ᔶⱘݙᆍDŽ⬅ѢᅗⳈ᥹߽⫼Ԣሖᑇৄⱘ㛑࡯ˈᗻ 䆌໮ϾᎹ԰⌕ᑊথ䖯㸠ˈҢ㗠㓧㾷њᇍCPU੠㋏㒳ᘏ㒓ⱘय़࡯ˈՓᕫᑨ⫼㛑໳䖤㸠ᕫ᳈ᖿDŽ߽⫼ ܕˈࡳ㛑ˈ੠߽⫼CPUᅠ៤ৠϔӏࡵⳌ↨ˈ⹀ӊࡴ䗳ⱘᬜ⥛᳈催DŽ⬅Ѣ⹀ӊࡴ䗳ߚ⾏њϔ䚼ߚᎹ԰ܙ ฿ 䆌໮⹀ӊᑇৄ੠ᅗӀⱘ᪡԰㋏㒳䛑ᦤկ෎ᴀⱘ⹀ӊࡴ䗳ᬃᣕDŽ՟བˈ⹀ӊࡴ䗳ϔ㠀ᦤկⶽᔶ Փ⫼VolatileImage 3.8

下载pdf到电脑,查找使用更方便

pdf的实际排版效果,会与网站的显示效果略有不同!!

需要 5 金币 [ 分享pdf获得金币 ] 4 人已下载

下载pdf

pdf贡献者

wujingpan

贡献于2012-07-15

下载需要 5 金币 [金币充值 ]
亲,您也可以通过 分享原创pdf 来获得金币奖励!
下载pdf