--Wfe1KbQWcwuymTys
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

tony summerfelt (snowzone5 / hotmail.com) wrote:

> On Wed, 21 Jul 2004 01:20:56 +0900, you wrote:
> 
> >The methods inside them can be called concurrently from multiple
> >threads.
> 
> >Note that this is not the same as reentrant, where the same method can
> >be safely executing simultaneously in two threads.
> 
> when i first read this i thought ok, that answers my question...but
> after over thinking it,  i'm not sure i see the difference.
> 
> i would think the same  method  running in two different threads is
> either safely executing or it isn't.

I didn't explain it very well, and my definition may be a little off
(its rather subtle, but there).  When you have a thread-safe method, it
can be called multiple times concurrently, but you may have only one
thread executing in the method, while the others are blocked waiting.

(Of course, you may have more than one critical section, or a critical
section only around a small part of the method.  Only one thread can be
executing inside a critical section.)

When you have a reentrant method, there are no critical sections, so N
threads can safely execute in the method at the same time.

In case that's not clear, here's an even better description:

http://weblogs.asp.net/oldnewthing/archive/2004/06/29/168719.aspx

> >Thread safety can be implemented easily by adding the appropriate
> >mutexes.  Making a module reentrant requires more care.
> 
> i've gone to considerably length to make sure methods in my module are
> thread safe as they access the same resource. i've leaned on them
> pretty heavily, with threaded code and the resource never gets
> corrupted..
> 
> just wanted to make sure i was on the right track...

Yep!  

-- 
Eric Hodel - drbrain / segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04


--Wfe1KbQWcwuymTys
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQFA/X/6MypVHHlsnwQRAnUgAKDVRa9dCqaiKhUfjzwi9MR/6A3n+ACfS3P0
0tE17IJCc8zXB7vgF4JVV6Att
-----END PGP SIGNATURE-----

--Wfe1KbQWcwuymTys--