首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

多线程安全有关问题案例1 单例注入的类中含非线程安全属性

2012-10-13 
多线程安全问题案例1 单例注入的类中含非线程安全属性在50个线程并发的情况下出现数组越界异常,经排查原因

多线程安全问题案例1 单例注入的类中含非线程安全属性

在50个线程并发的情况下出现数组越界异常,经排查原因为某一个类为单例注入,但含有非线程安全属性。详细如下

?

1、异常现象:数据越界

public class AtHelper {//    ……//    ……        public AtHelper() throws MalformedPatternException{//        ……//        ……    }        private List<String> doFilter(String content) {//        ……        PatternMatcher  matcher  = new Perl5Matcher();        while (matcher.contains(input, pattern) == true) {            mResult = matcher.getMatch();            String uid = StringUtil.substring(mResult.toString(), 1);            uids.add(uid);        }        return uids;    }//    ……}
?

?

?

热点排行