Wake up on DataInputStream.readInt()?

Hi all,

I am developing an application for two mobiles that communicate using Bluetooth. Communication is handled by a method containing several DataInputStream.readInt()'s. I noticed data missing because it is overwritten by either the method containing those readInts or events fired of by the users. I conclude I have a problem with accessing a shared resource.

I can solve this problem using threads. But I am wondering if there is not something I miss. Like a wakeup call from an input stream. What I mean is I put the reading of the data in a seperate thread and wait for a wake-up call when data is available. Is there something like that, of do I need to check regularly whether data is available to be read.

Maik

[747 byte] By [Maik] at [2007-11-26 12:15:59]
# 1
Hi,I don't know what you say. readInt will block till there is data.Kaj
kajbj at 2007-7-7 14:51:25 > top of Java-index,Archived Forums,Socket Programming...