Created
September 1, 2012 11:03
-
-
Save mikaelhg/3569814 to your computer and use it in GitHub Desktop.
JBoss Byteman demo http://stackoverflow.com/questions/12187369
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 characters
public class Foo { | |
public void test1() { | |
long timeout = System.currentTimeMillis() + 500; | |
int i = 0; | |
while (System.currentTimeMillis() < timeout) { | |
System.out.println(i++); | |
try {Thread.sleep(50);} catch (Exception ex) {} | |
} | |
} | |
public static void main(final String ... args) throws Exception { | |
new Foo().test1(); | |
} | |
} |
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 characters
RULE counter | |
CLASS Foo | |
METHOD test1 | |
AT ENTRY | |
IF TRUE | |
DO createCountDown($0, 5) | |
ENDRULE | |
RULE sleeper | |
CLASS Foo | |
METHOD test1 | |
AT INVOKE Thread.sleep() | |
IF countDown($0) | |
DO RETURN | |
ENDRULE |
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 characters
$ ~/Downloads/byteman-download-2.1.0/bin/bmjava.sh -l ./sleeper.btm Foo | |
0 | |
1 | |
2 | |
3 | |
4 | |
5 | |
$ java Foo | |
0 | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment