[4315] in java-interest

home help back first fref pref prev next nref lref last post

Example of MT read/write on IO stream?

daemon@ATHENA.MIT.EDU (Gary Joseph Bowdridge)
Sat Dec 16 00:38:28 1995

From: grover@ra.isisnet.com (Gary Joseph Bowdridge)
To: java-interest@java.Eng.Sun.COM
Date: Fri, 15 Dec 1995 22:13:49 -0400 (AST)



  Argh. I'm desperetly looking for a, sumwhat simplified, example
of code to read and write to a single DataInputStream at the
same time.. that is the read is independant of the write, OR
one can at least write if there is nothing there to read at the
time (if available was implemented, that would work i think)... 
But i'll take anything you have to offer.

  I'm a java novice (heh. isn't everyone), but from where i stand it 
looks impossiable.

 since you can't do non-blocking-reads (can you?!), and
aviable() isn't really implemented anywere (is it?!), i assume
the only way to go is to create two threads, one to read, one
to write.. But when i do this, the threads don't seem to 
run independantly. The write thread takes from System.in and writes
to the Stream no prob, but only after a write will the
read Thread take from the Stream and write to System.out... 

 I belive this may have sumthing to do with the the DataInputStream's
read, and write methods being syncronized?! (I could be way off,
as i'm also sumwhat new to the concept of MT)..

  If all you can give are a few lines of direction/advice on
what to look for it'd be appreicated.

Thanks,
grover@ra.isisnet.com
_Gary_
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post