重发数据包优先
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user