From ce6ae1b56e4f6548dc19974474c8ee2d8cece13a Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Tue, 3 Feb 2009 18:00:24 -0500 Subject: Fixed [Gotez06] InterruptedException violation --- .../gamestate/mapview/event/EventCall.java | 5 ++--- .../gamestate/mapview/event/SpecialEvent.java | 23 ++++++++-------------- .../mapview/event/specialmove/MoveEventThread.java | 16 +++++---------- .../mapview/event/specialmove/StepMoveEvent.java | 4 +--- .../mapview/event/specialmove/WaitMoveEvent.java | 4 +--- .../transition/TransitionCallbackThread.java | 4 +--- 6 files changed, 18 insertions(+), 38 deletions(-) (limited to 'src/com') diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java index c0c2c3b..f577cc2 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/EventCall.java @@ -5,7 +5,6 @@ package com.fourisland.fourpuzzle.gamestate.mapview.event; -import com.fourisland.fourpuzzle.gamestate.mapview.Map; import java.util.concurrent.Future; /** @@ -22,9 +21,9 @@ public abstract class EventCall extends SpecialEvent implements Runnable { } }; } - - public abstract void run(); + public abstract void run(); + private Future isRunning = null; public void activate(EventCallTime calltime) { diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java index 43cf626..faa7a48 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java @@ -14,8 +14,6 @@ import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.FixedViewpoint; import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.MovingViewpoint; import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; import java.util.concurrent.CountDownLatch; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @@ -128,8 +126,9 @@ public class SpecialEvent { /** * Waits until all previously called MoveEvent()s have finished + * @throws InterruptedException */ - public void MoveEventWait() + public void MoveEventWait() throws InterruptedException { MoveEventThread.moveAll(); } @@ -166,14 +165,11 @@ public class SpecialEvent { * Waits for a specified interval * * @param wait The time to wait in milliseconds + * @throws InterruptedException */ - public void Wait(int wait) + public void Wait(int wait) throws InterruptedException { - try { - Thread.sleep(wait); - } catch (InterruptedException ex) { - Logger.getLogger(SpecialEvent.class.getName()).log(Level.SEVERE, null, ex); - } + Thread.sleep(wait); } /** @@ -193,8 +189,9 @@ public class SpecialEvent { * @param length How long (in milliseconds) it will take to pan * @param block If true, the game will wait for the pan to complete * before executing any more commands + * @throws InterruptedException */ - public void PanViewpoint(final int x, final int y, int length, final boolean block) + public void PanViewpoint(final int x, final int y, int length, final boolean block) throws InterruptedException { Viewpoint viewpoint = mapView.getViewpoint(); final CountDownLatch blocker; @@ -220,11 +217,7 @@ public class SpecialEvent { if (block) { - try { - blocker.await(); - } catch (InterruptedException ex) { - Logger.getLogger(SpecialEvent.class.getName()).log(Level.SEVERE, null, ex); - } + blocker.await(); } } diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java index 2395dd0..d129303 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/MoveEventThread.java @@ -11,8 +11,6 @@ import com.fourisland.fourpuzzle.gamestate.mapview.event.LayerEvent; import java.util.List; import java.util.Vector; import java.util.concurrent.Semaphore; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @@ -37,7 +35,7 @@ public class MoveEventThread implements Runnable { try { moveEventWait.acquire(); } catch (InterruptedException ex) { - Logger.getLogger(MoveEventThread.class.getName()).log(Level.SEVERE, null, ex); + Thread.currentThread().interrupt(); } while (ev.isMoving()) @@ -45,7 +43,7 @@ public class MoveEventThread implements Runnable { try { Thread.sleep(2); } catch (InterruptedException ex) { - Logger.getLogger(MoveEventThread.class.getName()).log(Level.SEVERE, null, ex); + Thread.currentThread().interrupt(); } } @@ -74,14 +72,10 @@ public class MoveEventThread implements Runnable { return (events.contains(event)); } - public static void moveAll() + public static void moveAll() throws InterruptedException { - try { - moveEventWait.acquire(100); - moveEventWait.release(100); - } catch (InterruptedException ex) { - Logger.getLogger(MoveEventThread.class.getName()).log(Level.SEVERE, null, ex); - } + moveEventWait.acquire(100); + moveEventWait.release(100); } } diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/StepMoveEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/StepMoveEvent.java index d5d830e..af50087 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/StepMoveEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/StepMoveEvent.java @@ -7,8 +7,6 @@ package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove; import com.fourisland.fourpuzzle.Direction; import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; -import java.util.logging.Level; -import java.util.logging.Logger; /** * StepMoveEvent moves the event in the direction specified. @@ -32,7 +30,7 @@ public class StepMoveEvent implements MoveEvent { try { Thread.sleep(2); } catch (InterruptedException ex) { - Logger.getLogger(StepMoveEvent.class.getName()).log(Level.SEVERE, null, ex); + Thread.currentThread().interrupt(); } } } diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/WaitMoveEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/WaitMoveEvent.java index eb56b95..565365a 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/WaitMoveEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/WaitMoveEvent.java @@ -6,8 +6,6 @@ package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove; import com.fourisland.fourpuzzle.gamestate.mapview.event.Event; -import java.util.logging.Level; -import java.util.logging.Logger; /** * WaitMoveEvent pauses for the specifed amount of milliseconds. @@ -27,7 +25,7 @@ public class WaitMoveEvent implements MoveEvent { try { Thread.sleep(wait); } catch (InterruptedException ex) { - Logger.getLogger(WaitMoveEvent.class.getName()).log(Level.SEVERE, null, ex); + Thread.currentThread().interrupt(); } } diff --git a/src/com/fourisland/fourpuzzle/transition/TransitionCallbackThread.java b/src/com/fourisland/fourpuzzle/transition/TransitionCallbackThread.java index 58ea0b5..50eacc2 100644 --- a/src/com/fourisland/fourpuzzle/transition/TransitionCallbackThread.java +++ b/src/com/fourisland/fourpuzzle/transition/TransitionCallbackThread.java @@ -6,8 +6,6 @@ package com.fourisland.fourpuzzle.transition; import com.fourisland.fourpuzzle.Display; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @@ -28,7 +26,7 @@ public class TransitionCallbackThread implements Runnable { try { Thread.sleep(300); } catch (InterruptedException ex) { - Logger.getLogger(TransitionCallbackThread.class.getName()).log(Level.SEVERE, null, ex); + Thread.currentThread().interrupt(); } } -- cgit 1.4.1