aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/util/RunnableExecutor.java
blob: 6f18f5480130dd73ee132da7c3dee6bf464e355a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.jogamp.common.util;

public interface RunnableExecutor {
    /** {@link RunnableExecutor} implementation simply invoking {@link Runnable#run()}, 
     *  i.e. on the current thread at the time of calling {@link #invoke(boolean, Runnable)}.
     */
    public static final RunnableExecutor currentThreadExecutor = new CurrentThreadExecutor();
    
    /**
     * @param wait if true method waits until {@link Runnable#run()} is completed, otherwise don't wait.  
     * @param r the {@link Runnable} to be executed.
     */
    void invoke(boolean wait, Runnable r);
    
    static class CurrentThreadExecutor implements RunnableExecutor {
        private CurrentThreadExecutor() {}
        
        @Override
        public void invoke(boolean wait, Runnable r) {
            r.run();            
        }        
    }
}