Created
December 6, 2012 22:25
-
-
Save shannah/4229057 to your computer and use it in GitHub Desktop.
Excerpt from Statemachine that responds to button press to perform benchmark.
This file contains 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 characters
protected void onMain_BtnTowerOfHanoiAction(Component c, ActionEvent event) { | |
final Label towerOfHanoiLabel = this.findLblTowerOfHanoi(); | |
towerOfHanoiLabel.setText("Calculating.... Please wait"); | |
if ( isCalculatingHanoi ){ | |
return; | |
} | |
isCalculatingHanoi = true; | |
Thread t = new Thread(new Runnable(){ | |
public void run() { | |
long start = System.currentTimeMillis(); | |
TowersOfHanoi.move(30, 1, 3); | |
long end = System.currentTimeMillis(); | |
calculationTime = end - start; | |
isCalculatingHanoi = false; | |
Display.getInstance().callSerially(new Runnable(){ | |
public void run() { | |
towerOfHanoiLabel.setText("Calculation took "+calculationTime+"ms"); | |
} | |
}); | |
} | |
}); | |
t.start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment