> when you say this method is thread safe
>
> you guarantee there is only one thread access this
> method at atime
Actually the truth is nearly the opposite. When you say some piece of code is thread safe, you are saying it's written in such a way that it's safe for serveral threads to be running it at the same time. That may involve protecting parts of the code with synchronized, but it's mostly about being careful with common state data.
It's when code isn't thread safe you may need to synchronize it.
> > when you say this method is thread safe
> >
> > you guarantee there is only one thread access
> this
> > method at atime
>
> Actually the truth is nearly the opposite. When you
> say some piece of code is thread safe, you are saying
> it's written in such a way that it's safe for
> serveral threads to be running it at the same time.
> That may involve protecting parts of the code with
> synchronized, but it's mostly about being careful
> with common state data.
>
> It's when code isn't thread safe you may need to
> synchronize it.
ooh sorry thanks malc u r right
Can you explain what you mean by "single threaded object"?
I have never heard of such a thing. You can have an application with one thread or multiple threads and an object may be referenced by multiple threads. Do you mean an object that is only allowed to exist on a single thread? Are you talking about ThreadLocal objects?
Ted.
How do I make a single threaded ?
To make Thread safe we use synchronized keyword
I need more clarity on this
It will be great if somebody can explain with a very simple example
DrLaszloJamf & Peetzore, I think you people can give me more detailed answer.
thnx
> How do I make a single threaded ?
> To make Thread safe we use synchronized
> keyword
>
> I need more clarity on this
>
You sir are a complete bafoon.
Do you is needing more clarify on this? I'll put some text in bold too for no reason.
Ted.