package org.kne.io; public abstract class Task implements Runnable{ private volatile boolean begin=false,end=false; private volatile Object t=new Object(); @Override public void run() { begin=true; runTask(); end=true; if(t!=null) { synchronized(t) { t.notifyAll(); } } } public void waitfortask() { synchronized(t){ try { while(!end) { t.wait(1); } } catch (InterruptedException e) { e.printStackTrace(); }} } protected abstract void runTask(); }