如題: 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
提交
取消