AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Stack and Thread Safety

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Kenneth P. Turvey
Guest





PostPosted: Tue Jun 29, 2004 11:57 pm    Post subject: Stack and Thread Safety Reply with quote



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





PostPosted: Wed Jun 30, 2004 12:41 pm    Post subject: Re: Stack and Thread Safety Reply with quote




"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





PostPosted: Wed Jun 30, 2004 2:07 pm    Post subject: Re: Stack and Thread Safety Reply with quote



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





PostPosted: Wed Jun 30, 2004 11:32 pm    Post subject: Re: Stack and Thread Safety Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.