class ContextRefreshThread extends TimerTask {

    private static final long PERIOD = 500;
    private final Timer timer;
    private final GraphModel graphModel;
    private final Runnable listener;
    private int previousVersion = -1;

    public ContextRefreshThread(GraphModel graphModel, Runnable listener) {
        this.timer = new Timer("Context Refresh Thread", true);
        this.graphModel = graphModel;
        this.listener = listener;

        //Schedule
        timer.schedule(this, PERIOD, PERIOD);
    }

    @Override
    public void run() {<FILL_FUNCTION_BODY>}

    public void shutdown() {
        timer.cancel();
    }
}

        Graph graph = graphModel.getGraphVisible();
        int graphVersion = graph.getVersion();
        if (graphVersion != previousVersion) {
            listener.run();
        }
        previousVersion = graphVersion;
    
<methods>public boolean cancel() ,public abstract void run() ,public long scheduledExecutionTime() <variables>static final int CANCELLED,static final int EXECUTED,static final int SCHEDULED,static final int VIRGIN,final java.lang.Object lock,long nextExecutionTime,long period,int state