import java.lang.*; import twinfeats.util.*; import twinfeats.io.*; import java.io.*; public class ConfRecorder extends WorkThread implements Work { Queue que; FileOutputStream fos; ObjectOutputStream oos; String name; Thread thread; boolean stop; public ConfRecorder(String n) throws IOException { name = n; fos = new FileOutputStream(n); oos = new ObjectOutputStream(fos); que = new Queue("ConfRecorder "+n); setWork(this); start(); } public void record(CommMessage msg) { synchronized (que) { que.push(msg); } } public void stop() { stop = true; } public void doWork() { que.setReady(true); CommMessage msg; // byte[] b; while (true) { synchronized (que) { if (stop && que.isEmpty()) break; msg = (CommMessage)que.pop(); } try { /* b = msg.getHeader().getBytes(); fos.write(b); b = msg.getBytes(); fos.write(b); */ oos.writeObject(msg.getHeader()); oos.writeObject(msg); } catch (Exception e) { e.printStackTrace(); } } try { oos.flush(); oos.close(); } catch (Exception e2) { } } }