Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

is DataOutputStream synchronized or not?  RSS feed

 
Daniil Sosonkin
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java api doc says no synchronisation
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!