Article View: borland.public.jbuilder.java.language
Article #17334Re: How thread-safe is a Vector?
From: Tor Iver Wilhelmsen
Date: Tue, 01 Dec 1998 00:00
Date: Tue, 01 Dec 1998 00:00
18 lines
1170 bytes
1170 bytes
Steve Horsley <steve.horsley@cwcom.co.uk> writes: > I guess I want to just take a snapshot of the Vector, then enumerate > that. Would requests.clone() be thread safe, or do I have to synchronize > every bit of code that accesses the Vector explicitly? Most methods in java.util.Vector are synchronized, including clone(). But as you have discovered, the VectorEnumerator operates on the existing Vector, and is _not_ synchronized. You could extend Vector and make an Enumeration which _was_ thread-safe. > Secondly, would that error have killed the thread that was doing the > enumeration? Most likely. Try adding try...catch around code which is _likely_ to throw runtime exceptions.
Technical Details
Message-ID:
<uemqkrtu6.fsf@sds.no>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<365D4BD5.1AC0@cwcom.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,51f3325897926eb9 X-Google-Attributes: gidf74b3,public From: Tor Iver Wilhelmsen <tor.wilhelmsen@sds.no> Subject: Re: How thread-safe is a Vector? Date: 1998/12/01 Message-ID: <uemqkrtu6.fsf@sds.no> X-Deja-AN: 417435286 Sender: towi@SDSA1761 References: <365D4BD5.1AC0@cwcom.co.uk> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.language