import Service; import java.io.*; import ThreadMutex; // the thread to execute a service on it's own. public class ServiceExecutorThread extends Thread { // the service that we'll be executing private Service ServiceToExecute; // the output print stream PrintStream Outstream; // return status boolean ReturnStatus; // the thread mutex ThreadMutex Mutex; // the constructor ServiceExecutorThread(Service service, ThreadMutex mutex) { ServiceToExecute = service; ReturnStatus = false; Mutex = mutex; } // get the return status boolean getReturnStatus() { return ReturnStatus; } // the run function. public void run() { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(10240000); // create a temp print stream PrintStream out = new PrintStream(byteStream); // just attempt to execute the service ReturnStatus = ServiceToExecute.executeService(out); // output the bytestream to the mutex's output stream Mutex.outputToStream(byteStream); // decrement the thread counter to signify // that I'm done Mutex.decrementThreadCount(); } }