> -----Original Message-----
> From: Berin Loritsch [mailto:[EMAIL PROTECTED]]
> Sent: den 17 juli 2001 15:19
> To: Avalon Development
> Subject: Re: [Patch] New Avalon Docs
>
> > - Component is required to serialize access to shared resources.
> > - Component will not receive any context/session objects, as
> it is shared
> > among different contexts/sessions.
>
> Your first bullet applies.
>
> Your second bullet is (I think) a little off.
I agree. I didn't quite understand what you meant, and tried to fit my
non-understanding into a simple sentence.
I tried to fit this into a simple sentence, but I couldn't make it shorter
than your example. I think just specifying "thread-safe" is enough. That
concept contains so much that the only way to really specify what it means
is to look up thread-safe on Google or buy a book and read it.
> > A component whose methods are all fully reentrant is by definition
> > thread-safe.
>
> Not necessarily.
>
> In my previous example, each method above can be fully reentrant--but
> due to the specific ordering between method calls, it precludes
> ThreadSafe.
But since there is a specific ordering they must access some shared resource
and are thus not reentrant. If they were re-entrant the only resources they
access are those in the parameters passed to them, and then they would be
thread-safe, provided that the caller doesn't do something stupid with the
parameters.
For example
interface NotThreadSafe {
public void setStrings (String[] strings); /* must be called first */
public void sort (); /* must be called after setStrings */
public void pickFirst (); /* must be called after sort */
}
is not re-entrant code, as sort and pickFirst operate on the array of
Strings set in setStrings.
interface ThreadSafe {
public void sort (String[] strings);
public String pickFirst (String[] strings);
}
Is reentrant code, and thread-safe, and would be used like:
ThreadSafe threadSafe = ...
Strings[] myStrings = {"a", "b"};
threadSafe.sort (myStrings);
String firstInSorted = threadSafe.pickFirst (myStrings);
> This is the difference between a method being reentrant and a Component
> being reentrant.
Maybe I got the definitions wrong, but the definition of reentrant I use is
"not accesses any static data", but as the text talked about C programming,
this has to be extended to both class variables and member variables.
> Perhaps that is the word I should use: change "reentrant" to "reusable".
"thread-safe". You'll end up writing a book on thread-safety otherwise.
/LS
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]