| Author |
is DataOutputStream synchronized or not?
|
Daniil Sosonkin
Ranch Hand
Joined: Jan 15, 2004
Posts: 76
|
|
Hello, I'm wondering whether DataOutputStream is synchronizing all its writes. In my scenario I have a thread which sends out streaming data on DataOutputStream and then another thread which sends out a small ping to the client every minute or so. Should I synchronize my message output function? Thanx
|
 |
sander hautvast
Ranch Hand
Joined: Oct 18, 2002
Posts: 71
|
|
|
java api doc says no synchronisation
|
 |
peter wooster
Ranch Hand
Joined: Jun 13, 2004
Posts: 1033
|
|
Originally posted by Daniil Sosonkin: Hello, I'm wondering whether DataOutputStream is synchronizing all its writes. In my scenario I have a thread which sends out streaming data on DataOutputStream and then another thread which sends out a small ping to the client every minute or so. Should I synchronize my message output function? Thanx
If one of these activities is streamed data, you will need to interrupt the stream to send your ping, which I assume is a keepalive. You should probably have the partner send a response every so often saying that they have received data and only send the keepalive if this response doesn't come within a particular time. If the ping isn't a keepalive, but serves some other purpose, you should use a second connection.
|
 |
 |
|
|
subject: is DataOutputStream synchronized or not?
|
|
|