日期:2014-05-20 浏览次数:20853 次
public class Test implements Runnable{
public static int byteArrayToInt(byte[] b) {
int value= 0;
for (int i = 0; i < b.length; i++) {
int shift= (b.length - 1 - i) * 8;
value +=(b[i ] & 0x000000FF) << shift;
}
return value;
}
static LinkedList<Runnable> runnables = new LinkedList<Runnable>() ;
public static void main(String[] args){
for (int i = 0; i < 10; i++) {
TestFileOutput fileOutput = new TestFileOutput() ;
runnables.add(fileOutput) ;
}
new Thread(new Test()).start() ;
}
public static void add(TestFileOutput fileOutput){
runnables.add(fileOutput) ;
}
@Override
public void run() {
while(runnables.size()> 0){
runnables.removeFirst().run() ;
}
}