public class myPolSchema {
private String GrpContNo;
private String GrpPolNo;
public String getGrpContNo() {
return GrpContNo;
}
public void setGrpContNo(String aGrpContNo) {
GrpContNo = aGrpContNo;
}
public String getGrpPolNo() {
return GrpPolNo;
}
public void setGrpPolNo(String aGrpPolNo) {
GrpPolNo = aGrpPolNo;
}
public myPolSchema(String GrpContNo,String GrpPolNo){
this.GrpContNo=GrpContNo;
this.GrpPolNo=GrpPolNo;
}
public boolean equals(Object otherObject) {
if (this == otherObject)
return true;
if (otherObject == null)
return false;
if (getClass() != otherObject.getClass())
return false;
if(!(otherObject instanceof myPolSchema)){
return false;
}else{
myPolSchema other = (myPolSchema) otherObject;
return GrpContNo.equals(other.getGrpContNo())
&& GrpPolNo.equals(other.getGrpPolNo());
}
}
}
---------------------------
import java.util.* ;
public class MultiThreading{
// implements Runnable
Map m=Collections.synchronizedMap(new HashMap());
//HashMap m=new HashMap();
Hashtable t=new Hashtable();
public myPolSchema polschema;
public void run(int i)
{
polschema=new myPolSchema(i+"",i+"");
m.put(polschema, "UPDATE");
System.out.println("put end at " + new Date());
}
public static void main(String[] args) throws Exception {
MultiThreading t=new MultiThreading();
for(int i=0;i<=25000;i++){
try{
t.run(i);
//Thread.sleep(100);
}
catch(Exception ex){
//在我本地测试时当运行大概1500左右次的时间就会抛出NullPointerException
System.out.println("i is: " + i);
throw ex;
}
}
}
}
构造方法啊大哥 不赋值怎么能比较呢
回复 更多评论