Created
April 27, 2011 15:30
-
-
Save dfox/944478 to your computer and use it in GitHub Desktop.
Revisions
-
David Fox revised this gist
Apr 27, 2011 . 1 changed file with 3 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,7 @@ public interface Callback { void completed(); } public class AsynchronousTask extends Thread { private Callback callback; -
David Fox revised this gist
Apr 27, 2011 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,9 +27,6 @@ public void run() { callback.completed(); } public int getResult() { return result; } -
David Fox created this gist
Apr 27, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ package co.cantina.async; /** * An contrived example of an asynchronous task class. * * @author David Fox */ public class AsynchronousTask extends Thread { private Callback callback; private int result; public AsynchronousTask(final Callback callback){ this.callback = callback; } @Override public void run() { try { //Do some "work" sleep(5); result = 42; } catch (InterruptedException ex) { } callback.completed(); } /** * @return the result */ public int getResult() { return result; } }