Created
November 23, 2010 07:42
-
-
Save cscotta/711414 to your computer and use it in GitHub Desktop.
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
| import java.util.Timer; | |
| import java.util.TimerTask; | |
| import java.lang.reflect.Method; | |
| public class Abomination { | |
| String callback; | |
| public static void main(String args[]) { | |
| new Abomination().setInterval("lol", 1000); | |
| } | |
| void setInterval(String callback, long interval) { | |
| this.callback = callback; | |
| new Timer().scheduleAtFixedRate(setInterval, 0, 1000); | |
| } | |
| public void lol() { | |
| System.out.println("lol"); | |
| } | |
| TimerTask setInterval = new TimerTask() { | |
| public void run() { | |
| try { | |
| Method method = Abomination.this.getClass().getMethod(callback, new Class[]{}); | |
| method.invoke(Abomination.this.getClass().newInstance(), new Object[]{}); | |
| } catch (Exception e) { e.printStackTrace(); } | |
| } | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment