问题:
多线程方法中使用了共享变量SimpleDateFormat,报如下错误:
java.lang.NumberFormatException: multiple points
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1084
原因:
SimpleDateFormat是线程不安全的,切忌切忌!
解决:
在线程方法中,new SimpleDateFormat();
例:
SimpleDateFormat sdf = new SimpleDateFormat();
class QueryUserByNoThread extends Thread{
LoginOpr loginOpr;
CountDownLatch countdown ;
Map map;//构造返回信息
Group group;
String grpUId;
SimpleDateFormat sdf;
List listCust;
List listMem;
List listUser;
User user;
Map member = new HashMap();
/**
* @param bo
* @param loginOpr
*/
public QueryUserByNoThread(LoginOpr loginOpr,CountDownLatch cdown,Map member,Group group,String grpUId,List listCust,List listMem,List listUser,User user,Map map) {
super();
this.member.putAll(member);
this.countdown = cdown;
this.map = map;
this.group=group;
this.grpUId = grpUId;
this.sdf = new SimpleDateFormat(Constants.DATE_MODEL_8);
this.listMem = listMem;
this.listUser = listUser;
this.loginOpr = loginOpr;
this.user=user;
}