How to queue and call actual methods (rather than immediately eval) in java?
        Posted  
        
            by alleywayjack
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by alleywayjack
        
        
        
        Published on 2010-06-10T23:08:33Z
        Indexed on 
            2010/06/10
            23:12 UTC
        
        
        Read the original article
        Hit count: 214
        
There are a list of tasks that are time sensitive (but "time" in this case is arbitrary to what another program tells me - it's more like "ticks" rather than time). However, I do NOT want said methods to evaluate immediately. I want one to execute after the other finished. I'm using a linked list for my queue, but I'm not really sure how/if I can access the actual methods in a class without evaluating them immediate.
The code would look something like...
LinkedList<Method> l = new LinkedList<Method>();
l.add( this.move(4) );
l.add( this.read() );
l.removeFirst().call();
//wait 80 ticks
l.removeFirst().call();
move(4) would execute immediately, then 80 ticks later, I would remove it from the list and call this.read() which would then be executed.
I'm assuming this has to do with the reflection classes, and I've poked around a bit, but I can't seem to get anything to work, or do what I want. If only I could use pointers...
© Stack Overflow or respective owner