代碼編寫情況: 1:在自動加載的service里 調用Integer id = NodesUtils.getParentNodes(cityid);(我懷疑這句話取出值的時候id 會取錯值)2:工具類的靜態方法如下,nodeList 為全局變量 public static Integer getParentNodes(Integer childid) {
? ? ? ?if(nodeList == null && childid == null) return null;
? ? ? ?Node parentNode = new Node();
? ? ? ?for(Node mu: nodeList){ ?
? ? ? ? ? ?//遍歷出父id等于參數的id,add進子節點集合 ?
? ? ? ? //Integer比較特別,不能直接拿兩個Integer比較,相同值卻有可能結果為false
? ? ? ? ? ?if(mu.getId().intValue() == childid.intValue()){ ?
? ? ? ? ? ? parentNode = mu;
? ? ? ? ? ? break;
? ? ? ? ? ?} ?
? ? ? ?} ?
? ? ? ?return parentNode!=null&&parentNode.getParentId()!=null?parentNode.getParentId():0;
? ?}
我:
3:此為工具類所有代碼public ?class NodesUtils {
private ?static List<Node> ?nodeList=new ArrayList<Node>();
static{
init();
}
private static List<Node> init(){
Node node1 = new Node( 100,"北京",10 );
Node node2 = new Node( 2600,"天津",10 );
Node node3 = new Node( 909,"唐山",10 );
nodeList.add(node1);
nodeList.add(node2);
nodeList.add(node3);
}
}
我懷疑1處的代碼會不會在并發的時候 出現錯誤,然后第二個疑問是比如a,b,c同時登陸,這個list會不會加載多條相同記錄?
添加回答
舉報
0/150
提交
取消