Icklepebble
Technical User
Hi, I'm having a little trouble
I create two threads which are supposed to take objects from a stream, process them and return them to the main thread. So, I've created the threads, and connected them to the main thread using pipes, (one in and one out for each thread). Now I want to pass objects down these pipes, so I've got:
//Pipe created in main thread
PipedInputStream pipeIn = new PipedInputStream();
//Connect this pipe to the out pipe in thread1
thread1.out.connect(pipeIn);
//Now create object stream on this pipe
ObjectInputStream in = new ObjectInputStream(pipeIn);
The problem is that when I run the code, it hangs at the ObjectStream creation. No exceptions are thrown, and the system doesn't crash, it just appears to stop. i.e. If I put a print statement after, I never see it.
I hope somebody can see what I've done wrong... (or suggest a better way to pass objects between threads). Many thanks in advance for any response.
Matt
I create two threads which are supposed to take objects from a stream, process them and return them to the main thread. So, I've created the threads, and connected them to the main thread using pipes, (one in and one out for each thread). Now I want to pass objects down these pipes, so I've got:
//Pipe created in main thread
PipedInputStream pipeIn = new PipedInputStream();
//Connect this pipe to the out pipe in thread1
thread1.out.connect(pipeIn);
//Now create object stream on this pipe
ObjectInputStream in = new ObjectInputStream(pipeIn);
The problem is that when I run the code, it hangs at the ObjectStream creation. No exceptions are thrown, and the system doesn't crash, it just appears to stop. i.e. If I put a print statement after, I never see it.
I hope somebody can see what I've done wrong... (or suggest a better way to pass objects between threads). Many thanks in advance for any response.
Matt