Computer Science Canada ImageIO.read() returns null |
Author: | HappyCamper5 [ Thu Jan 01, 2009 12:52 pm ] | ||||||||||
Post subject: | ImageIO.read() returns null | ||||||||||
Right now I have 2 threads, one that constantly takes screenshots and sends it over to the other thread, and the other thread just displays them. I have a loop that takes a screenshot every 2 seconds, and stores it in a bufferedimage, then I send the image through
oos is an OutputStream. On the other side, I have
where the ois is an InputStream. The problem I have is that currentImage is still null even after calling the read(). Before the read method, I have the sender to send a byte of data to the receiver telling it that an image has been sent, and it can call the read(). However, this works for the first screenshot sent, and after the read() returns null, even though the write() has been called prior to the invocation of the read(). The code for the sender is:
And the code for the receiver is:
Mod Edit: Syntax tags are better then quotes for code :)
|
Author: | OneOffDriveByPoster [ Sat Jan 03, 2009 9:54 am ] |
Post subject: | Re: ImageIO.read() returns null |
The lack of wait() and notify() concerns me. Check the API docs for Object. |
Author: | rizzix [ Sat Jan 03, 2009 12:48 pm ] |
Post subject: | RE:ImageIO.read() returns null |
Take advantage of the Java Concurrent API: java.util.concurrent.Exchanger |