| View previous topic :: View next topic |
| Author |
Message |
Kenneth P. Turvey Guest
|
Posted: Tue Jun 29, 2004 11:57 pm Post subject: Stack and Thread Safety |
|
|
May I assume that a stack is thread safe since it extends the
synchronized vector class?
Thanks.
--
Kenneth P. Turvey <kt (AT) squeakydolphin (DOT) com>
Artificial Intelligence Algorithms Wiki
http://ai.squeakydolphin.com
|
|
| Back to top |
|
 |
Sebastian Scheid Guest
|
Posted: Wed Jun 30, 2004 12:41 pm Post subject: Re: Stack and Thread Safety |
|
|
"Kenneth P. Turvey" <kt (AT) squeakydolphin (DOT) com> schrieb im Newsbeitrag
news:slrnce40f4.j7h.kt (AT) premium (DOT) geo.yahoo.akadns.net...
| Quote: | May I assume that a stack is thread safe since it extends the
synchronized vector class?
|
No you cannot. Stack could have thread unsafe parts in it. But in fact it
has not. Its methods are synchronized. So Stack is threadsafe but not
because in extends Vector!
Sebastian
|
|
| Back to top |
|
 |
Chris Smith Guest
|
Posted: Wed Jun 30, 2004 2:07 pm Post subject: Re: Stack and Thread Safety |
|
|
Sebastian Scheid wrote:
| Quote: | No you cannot. Stack could have thread unsafe parts in it. But in fact it
has not. Its methods are synchronized. So Stack is threadsafe but not
because in extends Vector!
|
It's worth pointing out here that "thread-safe" is a rather vague term
here. To reason about correctness of a multithreaded program, you need
to do more than ask if everything you use is "thread-safe". For
example, if I needed to push three values consecutively onto a stack,
I'd still need to take out a monitor on that stack to ensure that the
set of tree push operations are atomic.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
|
| Back to top |
|
 |
Kenneth P. Turvey Guest
|
Posted: Wed Jun 30, 2004 11:32 pm Post subject: Re: Stack and Thread Safety |
|
|
On Wed, 30 Jun 2004 08:07:42 -0600, Chris Smith <cdsmith (AT) twu (DOT) net> wrote:
| Quote: | Sebastian Scheid wrote:
It's worth pointing out here that "thread-safe" is a rather vague term
here. To reason about correctness of a multithreaded program, you need
to do more than ask if everything you use is "thread-safe". For
example, if I needed to push three values consecutively onto a stack,
I'd still need to take out a monitor on that stack to ensure that the
set of tree push operations are atomic.
|
I understand the complexities of the problem. I was only doing a
single pop from the stack in each thread. Thanks for the help.
--
Kenneth P. Turvey <kt (AT) squeakydolphin (DOT) com>
Artificial Intelligence Algorithms Wiki
http://ai.squeakydolphin.com
|
|
| Back to top |
|
 |
|