我的目标是有包含在继承Thread其run方法弹出一个方法调用从队列中每15秒一次的一类方法调用的队列。这可以通过使用字符串,整数或字符在一个庞大的开关盒中以阴暗的方式完成,但是我想知道是否有其他人对此问题有更为优雅的解决方案。队列中的Java
东西会是这样的?
public class Potato extends Thread{
Queue<Methods> methodsQueue = new LinkedList<Methods>();
public Potato(){}
run(){
methodsQueue.poll();//This would execute a method
}
//Methods of this class...
}
我想你会想看看进入[反射API(https://docs.oracle .com/javase/tutorial/reflect /) –
看看执行器API – danielbathke
究竟是什么卡住了? – shmosel