Link to home
Start Free TrialLog in
Avatar of Knightley
Knightley

asked on

how to make InputStream and OutputStream thread safe.

well, have multiple clients connecting to a Socket Server,
some kind simple chat application.

are the InputStream and OutputStream thread safe,
or do i have do something special to ensure that.

thanx
Avatar of sciuriware
sciuriware

If they address different files there is no problem.

;JOOP!
Avatar of girionis
> are the InputStream and OutputStream thread safe,

They are since each time you will be getting the input/output stream of the coket connecting to the server.
Avatar of Knightley

ASKER

a server connected with several clients is always thread safe?
i rememer somebody told me it is not, but forget where.

so when i start a server:
1. accept several clients by creating a thread for each.
2. do some input and output
3. do some System.out.println

everything i did above are thread safe?

thanx
The IO is, the thread operations may not be.

;JOOP!
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also the ClientConnection class should implement Runnable. I forgot about it.
sorry sciuriware,

i received the CleanUp post, and give the points in a hurry.

in my defense, though your anwsers are correct and swift,
and should receive the points.

they are just so SHORT, i am afraid i overlooked them.

sorry again, if there is a way to send you the points,
tell me how. if not, i hope i could make it up to you somehow.

cu
No problem, you can't always  :)
This is an interesting forum,
sometimes you get points for almost nothing,
sometimes you work hard on a solution and ... nope.
Don't worry!

;JOOP!
You can still ask a question in Community Support to reopen the question and assign the points to sciuriwar.
I looked this over. Let it be as it is. Next question please ....
i think its alright. girionis, u help a lot too.

next time u anwser my question i will give it to
scicuriware. :)

thanx to u both.