Java Synchronized Write Block
Posted
by ikurtz
on Stack Overflow
See other posts from Stack Overflow
or by ikurtz
Published on 2010-05-14T12:50:10Z
Indexed on
2010/05/14
13:04 UTC
Read the original article
Hit count: 199
java
|synchronized-block
im new to java and i have a question regarding Synchronized.
i have the following code for writing to network (simple implementation for now):
public void networkSendData(byte[] data){
try {
out.write(data);
out.flush();
} catch (IOException e) {
}
}
i was wondering if there is a need for block level Synchronized here as im am writing the whole data at once. or is there a chance for race condition? i ask because the data to write is coming for multiple sources.
thank you.
© Stack Overflow or respective owner