<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    方偉的博客
    j2ee技術(shù)、網(wǎng)絡(luò)、web等,同名的人真多,我的QQ是20025404
    posts - 21,comments - 14,trackbacks - 0
         摘要: 對(duì)于volatile修飾的變量,jvm虛擬機(jī)只是保證從主內(nèi)存加載到線程工作內(nèi)存的值是最新的
    例如假如線程1,線程2 在進(jìn)行read,load 操作中,發(fā)現(xiàn)主內(nèi)存中count的值都是5,那么都會(huì)加載這個(gè)最新的值
    在線程1堆count進(jìn)行修改之后,會(huì)write到主內(nèi)存中,主內(nèi)存中的count變量就會(huì)變?yōu)?
    線程2由于已經(jīng)進(jìn)行read,load操作,在進(jìn)行運(yùn)算之后,也會(huì)更新主內(nèi)存count的變量值為6
    導(dǎo)致兩個(gè)線程及時(shí)用volatile關(guān)鍵字修改之后,還是會(huì)存在并發(fā)的情況。
      閱讀全文
    posted @ 2013-05-30 15:26 方偉的博客 閱讀(315) | 評(píng)論 (0)編輯 收藏
    /* *Author:tyfun *DateTime:2002.12.19 *Package:com.westarsoft.function */ package com.westarsoft.function; public class HtmlFilter { /*USE: *String escapeHTMLTags( String input , boolean htmlFlag ) */ public static String escapeHTMLTags( String input , boolean htmlFlag ) { if( input == null || input.length() == 0 || htmlFlag ) { return input; } StringBuffer buf = new StringBuffer(input.length()+6); char ch = '' ''; for( int i=0; i'' ) { buf.append( ">" ); } else { buf.append( ch ); } } return buf.toString(); } /*USE: *String replace( String line, String oldString, String newString ) */ public static String replace( String line, String oldString, String newString ) { int i=0; if ( ( line == null || oldString == null ) ) { return null; } if ( ( i=line.indexOf( oldString, i ) ) >= 0 ) { int oLength = oldString.length(); int nLength = newString.length(); StringBuffer buf = new StringBuffer(); buf.append(line.substring(0,i)).append(newString); i += oLength; int j = i; while( (i=line.indexOf(oldString,i)) > 0 ) { buf.append(line.substring(j,i)).append(newString); i += oLength; j = i; } buf.append(line.substring(j)); return buf.toString(); } return line; } /*USE: *String replaceIgnoreCase( String line, String oldString, String newString ) */ public static String replaceIgnoreCase( String line, String oldString, String newString ) { if (line == null) { return null; } String lcLine = line.toLowerCase(); String lcOldString = oldString.toLowerCase(); int i=0; if ( ( i=lcLine.indexOf( lcOldString, i ) ) >= 0 ) { char [] line2 = line.toCharArray(); char [] newString2 = newString.toCharArray(); int oLength = oldString.length(); StringBuffer buf = new StringBuffer(line2.length); buf.append(line2, 0, i).append(newString2); i += oLength; int j = i; while( ( i=lcLine.indexOf( lcOldString, i ) ) > 0 ) { buf.append(line2, j, i-j).append(newString2); i += oLength; j = i; } buf.append(line2, j, line2.length - j); return buf.toString(); } return line; } /*USE: *String convertUBB( String input ) */ public static String convertUBB ( String input ) { if( input == null || input.length() == 0 ) { return input; } else { input = replaceIgnoreCase( input , "<" ,"<" ) ; input = replaceIgnoreCase( input , "<%" ,"<%" ) ; input = replaceIgnoreCase( input , "%>" ,"%>" ) ; input = replaceIgnoreCase( input , ">" ,">" ) ; input = replaceIgnoreCase( input , "" ,"" ) ; input = replaceIgnoreCase( input , "" ,"" ) ; input = replaceIgnoreCase( input , "" ,"" ) ; input = replaceIgnoreCase( input , "" ,"" ) ; input = replaceIgnoreCase( input , "" ,"" ) ; input = replaceIgnoreCase( input , "" ,"" ) ; input = replaceIgnoreCase( input , "[red]" ,"" ) ; input = replaceIgnoreCase( input , "[/red]" ,"" ) ; input = replaceIgnoreCase( input , " " ,"
      " ) ; input = replaceIgnoreCase( input , " " ,"
    " ) ; input = replaceIgnoreCase( input , " " ,"
  • " ) ; input = replaceIgnoreCase( input , "" ,"
  • " ) ; input = replaceIgnoreCase ( input , " " , "

    " ) ; input = replaceIgnoreCase ( input , " " , "
    " ) ; input = replace ( input , " " ," " ) ; input = replace ( input , "\n" ,"
    " ) ; if ( input.indexOf("<") >= 0 ) { int oldPre = input.indexOf( "<" , 0 ) ; int oldEnd = input.indexOf( ">" , oldPre ) ; int tempInt = 0 ; StringBuffer setBlank = new StringBuffer () ; while ( oldPre >= 0 && oldEnd > 0 ) { setBlank = setBlank.append( input.substring( tempInt , oldPre) ) ; setBlank = setBlank.append ( replace ( input.substring( oldPre ,oldEnd ) , " " , " " ) ) ; tempInt = oldEnd ; oldPre = input.indexOf( "<" , oldEnd ) ; oldEnd = input.indexOf( ">" , oldPre ) ; } setBlank = setBlank.append ( input.substring( tempInt ) ) ; input = setBlank.toString() ; } } return input; } /*USE: *String convertURL( String input , boolean urlFlag ) */ public static String convertURL( String input , boolean urlFlag ) { if( input == null || input.length() == 0 || urlFlag || input.indexOf("[url") != -1 ) { return input; } else { StringBuffer buf = new StringBuffer(); int i = 0, j = 0, oldend = 0; int len = input.length(); char cur; while ( ( i=input.indexOf( "http://", oldend) ) >= 0 ) { j=i+7; cur = input.charAt(j); while (j < len) { if (cur == '' '') break; if (cur == ''<'') break; if (cur == ''\n'') break; if (cur == ''\r'' && j= 0 ) { j = i + tagPreLength ; j = input.indexOf( tagNameEnd , j ) ; if ( j < 0 ) { buf.append ( input.substring( oldend , len ) ) ; errorFlag = true ; break; } else { buf.append( input.substring(oldend,i)); buf.append( tagContentPre ); buf.append( input.substring(i + tagPreLength ,j)); buf.append( tagContentEnd ); buf.append( input.substring(i + tagPreLength ,j)).append( tagAttach ) ; } oldend = j + tagEndLength ; } if ( !errorFlag ) { buf.append(input.substring(j + tagEndLength,len)); } return buf.toString(); } catch ( IndexOutOfBoundsException IOBe ) { return input; } catch ( Exception e ) { return input; } } } // public static String convertSpecialTage ( String input , String tagNamePre , String tagNameEnd , String tagContentPre , String tagContentEnd ) { if( input == null || input.length() == 0 || input.indexOf( tagNamePre ) < 0 ) { return input; } else { try { StringBuffer buf = new StringBuffer(); int i = 0, j = 0, oldend = 0; int len = input.length(); int tagPreLength = tagNamePre.length() ; int tagEndLength = tagNameEnd.length() ; boolean errorFlag = false ; char cur; while ( ( i=input.indexOf( tagNamePre , oldend) ) >= 0 ) { j = i + tagPreLength ; j = input.indexOf( tagNameEnd , j ) ; if ( j < 0 ) { buf.append ( input.substring( oldend , len ) ) ; errorFlag = true ; break; } else { buf.append( input.substring(oldend,i)); buf.append( tagContentPre ); buf.append( input.substring(i + tagPreLength ,j)); buf.append( tagContentEnd ); } oldend = j + tagEndLength ; } if ( !errorFlag ) { buf.append( input.substring(j + tagEndLength,len)); } return buf.toString(); } catch ( IndexOutOfBoundsException IOBe ) { return input; } catch ( Exception e ) { return input; } } } // public static String convertSpecialTage ( String input , String tagNamePre , String tagNameEnd , String tagContentPre , String tagContentEnd , String tagAttach , String interval ) { if( input == null || input.length() == 0 || input.indexOf( tagNamePre ) < 0 ) { return input; } else { try { StringBuffer buf = new StringBuffer(); int i = 0, j = 0, oldend = 0; int len = input.length(); int tagPreLength = tagNamePre.length() ; int tagEndLength = tagNameEnd.length() ; int intervalLength = interval.length() ; boolean errorFlag = false ; String tempString = null ; char cur; while ( ( i=input.indexOf( tagNamePre , oldend) ) >= 0 ) { j = i + tagPreLength ; j = input.indexOf( tagNameEnd , j ) ; if ( j < 0 ) { buf.append ( input.substring( oldend , len ) ) ; errorFlag = true ; break; } else { int intervalPostion = input.indexOf( interval , i + tagPreLength ) ; if ( intervalPostion + intervalLength >= j ) { buf.append ( input.substring( oldend , len ) ) ; errorFlag = true ; break; } buf.append( input.substring(oldend,i)); buf.append( tagContentPre ); tempString = input.substring(i + tagPreLength ,intervalPostion ).trim() ; if ( tempString.indexOf("\"") == 0 ) { tempString = tempString.substring ( 1 , tempString.indexOf( "\"" , 1 ) ) ; } buf.append( tempString ); buf.append( tagContentEnd ); buf.append( input.substring( intervalPostion + intervalLength ,j ) ).append( tagAttach ) ; } oldend = j + tagEndLength ; } if ( !errorFlag ) { buf.append(input.substring(j + tagEndLength,len)); } return buf.toString(); } catch ( IndexOutOfBoundsException IOBe ) { return input; } catch ( Exception e ) { return input; } } } /*USE: *String convertIMG( String input ) */ public static String convertIMG ( String input ) { if( input == null || input.length() == 0 ) { return input; } else { return convertSpecialTage ( input , "" , "" ) ; } } /*USE: *String convertSupperUBB( String input , int level ) */ public static String convertSupperUBB ( String input , int level ) { if( input == null || input.length() == 0 ) { return input; } else { level++ ; if ( level-- > 0 ) input = convertSpecialTage ( input , "" , "" , "" , "" ) ; if ( level-- > 0 ) input = convertSpecialTage ( input , "[url=" , "][/url]" , "" , "" , "]" ) ; if ( level-- > 0 ) input = convertSpecialTage ( input , "[color=" ,"][/color]" , "" , "" , "]" ) ; if ( level-- > 0 ) input = convertSpecialTage ( input , "[size=" ,"][/size]" , "" , "" , "]" ) ; if ( level-- > 0 ) input = convertSpecialTage ( input , "" , "" , "" , "" ) ; if ( level-- > 0 ) input = convertSpecialTage ( input , "" , "" ) ; if ( level-- > 0 ) input = convertSpecialTage ( input , "[swf]" , "[/swf]" , "" ) ; if ( level-- > 0 ) input = convertSpecialTage ( input , "[url2]" , "[/url2]" , "" , "" ) ; if ( level-- > 0 ) input = convertSpecialTage ( input , "[url2=" , "][/url2]" , "" , "" , "]" ) ; if ( level-- > 0 ) input = convertSpecialTage ( input , "[a]" ,"[/a]" , "" ) ; if ( level-- > 0 ) input = convertSpecialTage ( input , "[div=" ,"][/div]" , "
    " , "
    " , "]" ) ; if ( level-- > 0 ) input = convertSpecialTage ( input , "[jsurl=" ,"][/jsurl]" , "" ,"" ,"]") ; if ( level-- > 0 ) input = convertSpecialTage ( input , "[class=" ,"][/class]" , "" , "" , "]" ) ; input = convertUBB ( input ) ; return input ; } } /*USE: *String convertMAIL( String input ) */ public static String convertMAIL ( String input ) { if( input == null || input.length() == 0 ) { return input; } else { return convertSpecialTage ( input , "" , "" , "" , "" ) ; } } /*USE: *String convertSWF( String input ) */ public static String convertSWF ( String input ) { if( input == null || input.length() == 0 ) { return input; } else { return convertSpecialTage ( input , "[swf]" , "[/swf]" , "" ) ; } } }
    posted @ 2005-07-13 16:03 方偉的博客 閱讀(567) | 評(píng)論 (1)編輯 收藏
    今天開始寫了
    posted @ 2005-07-13 15:55 方偉的博客 閱讀(544) | 評(píng)論 (1)編輯 收藏
    歡迎訪問!
    posted @ 2005-07-13 13:11 方偉的博客 閱讀(352) | 評(píng)論 (1)編輯 收藏
    僅列出標(biāo)題
    共3頁(yè): 上一頁(yè) 1 2 3 
    主站蜘蛛池模板: 国产亚洲情侣一区二区无码AV| 久久久亚洲欧洲日产国码aⅴ| a级男女仿爱免费视频| 亚洲人成网www| 国产精品美女自在线观看免费| 中文字幕av无码不卡免费 | 亚洲成在人线aⅴ免费毛片| 亚洲美女在线国产| 18级成人毛片免费观看| 美女被免费视频网站| 亚洲综合激情另类小说区| 免费女人18毛片a级毛片视频| 久久99精品免费视频| 亚洲AV噜噜一区二区三区| 亚洲成Av人片乱码色午夜| 成人永久免费福利视频网站| 无码国产精品一区二区免费模式 | 在线观看亚洲人成网站| 国产精品免费看久久久久| 四虎影视成人永久免费观看视频| 理论亚洲区美一区二区三区| 青青草原精品国产亚洲av| 亚洲精品在线视频| 青青草免费在线视频| 国产精品免费AV片在线观看| 真人无码作爱免费视频| 亚洲人成激情在线播放| 久久亚洲国产午夜精品理论片| 日本免费无遮挡吸乳视频电影| 久视频精品免费观看99| sihu国产精品永久免费| 亚洲欧美日韩一区二区三区在线| 亚洲AV美女一区二区三区| 亚洲国产综合久久天堂| 成人人观看的免费毛片| 亚洲第一网站免费视频| 免费无码又爽又刺激高潮软件| 边摸边脱吃奶边高潮视频免费| 亚洲精品无码久久久久A片苍井空| 中文字幕亚洲综合久久| 亚洲AV无码成人精品区天堂|