如题: class InitSocketThread extends Thread {
public void run() {
super.run();
try {
initSocket();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}求大神帮助啊,急求!!!!
1 回答
RISEBY
TA贡献1856条经验 获得超5个赞
class MyThreadScopeData{
//将类变成单例的
private MyThreadScopeData(){}
public static MyThreadScopeData getThreadInstance(){
MyThreadScopeData instance = map.get();
if(instance==null){
instance = new MyThreadScopeData();
map.set(instance);
}
return instance;
}
private static ThreadLocal map = new ThreadLocal();
public void initSocket(){
initSocket();
}
}
添加回答
举报
0/150
提交
取消