Dnia pon 22. marca 2004 13:30, Michael Stover napisał:
> To my way of thinking, getContext() should be entirely read-only and the
> initialization of thread contexts should be provided for prior to the
> test beginning.  That would avoid an unnecessary synchronization point.

I agree. I don't know if I can do it right, I'll try anyway
best regards,
Michal Kostrzewa

>
> -Mike
>
> On Mon, 2004-03-22 at 03:48, Michal Kostrzewa wrote:
> > Strange thing, I didn't notice your mail from wenesday, sorry :(
> >
> > > How would that cause a problem?  The Map that holds the thread contexts
> > > is only being read, not written to.  So, many threads can ask for their
> > > context simultaneously, this should not be a problem.  Unless you can
> > > think of a scenario that is problematic?
> >
> > Not exactly, because there is contextMap.get and then contextMap.put if
> > context was null - classic test-and-set problem. But I was also partly
> > wrong, because indeed the get and put works on the same context element
> > in only one thread.
> >
> > But this is not all - Is the HashMap used in this class synchronized? I
> > think it's not (HashTable is). So I think getContext should be
> > synchronized anyway.
> >
> >
> > ...
> > static private Map contextMap = new HashMap();
> > ...
> > static public JMeterContext getContext()
> >     {
> >         init();
> >         JMeterContext context =
> >             (JMeterContext)
> > contextMap.get(Thread.currentThread().getName()); if (context == null)
> >         {
> >             context = new JMeterContext();
> >             setContext(context);
> >         }
> >         return context;
> >     }
> >
> > In my problem (bug 27744) this was not the case. I fixed this bug and I'm
> > going to commit the patch (It is in the bugzilla already but nobody
> > tested it :(((
> >
> > :))))
> >
> > best regards,
> > Michał Kostrzewa
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To become a Jedi, use Emacs you have to.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to