StreamConnection in J2ME

I have:

StreamConnection opened for reading and writing. Two threads - one for reading, one for writing.

StreamConnection opened with address “stream://some_location:port”

When one thread do read(buf, 0, 256), another one won’‘t do flush() and inversly - if I do flush(), reader.ready() is “false” and after flush won’'t change to “true”. Why blocks is happend and how to resolve this problem? I trying to do sleep of one of the threads, trying to use “global” locking variable and use wait(), etc… =(((