Revision 17542 trunk/libraries/libAnimation/src/com/iver/cit/gvsig/animation/timer/AnimationTimer.java

View differences:

AnimationTimer.java
24 24
    }
25 25

  
26 26
	public void run() {
27
		while (true) {
28
			try {
29
				Thread.sleep((long) milis);
30
				synchronized (this) {
31
					if (finish) {
32
						break;
27
		if (isAlive()) {
28
			while (true) {
29
				try {
30
					Thread.sleep((long) milis);
31
					synchronized (this) {
32
						if (finish) {
33
							break;
34
						}
33 35
					}
36
				} catch (InterruptedException e) {
37

  
38
					e.printStackTrace();
34 39
				}
35
			} catch (InterruptedException e) {
36

  
37
				e.printStackTrace();
40
				// Updating
41
				Update();
38 42
			}
39
			//Updating 
40
			Update();
41 43
		}		
42 44
	}
43 45
	
......
68 70
	
69 71
	public void addCallBackObject(IUpdateCallBack object) {
70 72
		if (callBackList == null)
71
			callBackList =  new ArrayList(); 
72
		callBackList.add(object);
73
			callBackList = new ArrayList();
74
		if (!callBackList.contains(object)) {
75
			callBackList.add(object);
76
		}
73 77
	}
74 78

  
79
	public boolean isAlive() {
80
		if (thread != null)
81
			return thread.isAlive();
82
		else
83
			return false;
84
	}
85
	
75 86
  
76 87
}

Also available in: Unified diff