java:deadlock

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

java:deadlock [2015/03/30 04:37]
gthanos created
java:deadlock [2016/02/26 11:15]
Line 1: Line 1:
-====== Αδιέξοδο στην χρήση των πόρων και πως να το αποφύγετε ====== 
- 
-Δείτε τον παρακάτω κώδικα 
-<code java TreeNode.java>​ 
-public class TreeNode { 
-  
-  TreeNode parent ​  = null;  ​ 
-  List     ​children = new ArrayList();​ 
- 
-  public synchronized void addChild(TreeNode child){ 
-    if(!this.children.contains(child)) { 
-      this.children.add(child);​ 
-      child.setParentOnly(this);​ 
-    } 
-  } 
-  ​ 
-  public synchronized void addChildOnly(TreeNode child){ 
-    if(!this.children.contains(child){ 
-      this.children.add(child);​ 
-    } 
-  } 
-  ​ 
-  public synchronized void setParent(TreeNode parent){ 
-    this.parent = parent; 
-    parent.addChildOnly(this);​ 
-  } 
- 
-  public synchronized void setParentOnly(TreeNode parent){ 
-    this.parent = parent; 
-  } 
-  ​ 
-  public static void main(String args[]) { 
-    ​ 
-  } 
-} 
-</​code>​ 
  
java/deadlock.txt · Last modified: 2016/02/26 11:15 (external edit)