Skip to content

Instantly share code, notes, and snippets.

@mikaelhg
Created September 1, 2012 11:03
Show Gist options
  • Save mikaelhg/3569814 to your computer and use it in GitHub Desktop.
Save mikaelhg/3569814 to your computer and use it in GitHub Desktop.
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();
}
}
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
$ ~/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