Re: A new Critical Section for high contention situations




"Kürsat" <xx@xxxxxx> wrote in message
news:O6WqZyqtIHA.3604@xxxxxxxxxxxxxxxxxxxxxxx

You said "there is no synchroniztion", then, what does synchronization
mean? AFAIK, synchronization means "accepting only one thread to access
certain resource or functionality at a time". My object achive this, so, I
think, there is synchronization.

No, there isn't. You are synchronizing access to m_nLock only, not access
to the code that enter/leave() are supposed to protect. enter() is still
being allowed to exit immediately regardless of whether another thread
"owns" the lock. In order to synchronize properly, enter() must wait for
the lock to be released, if owned by other thread, before exiting. Your
object is not doing that at all. So multiple threads are still able to
access protected code unrestricted, defeating the whole purpose of a
synchronization object.


Gambit


.



Relevant Pages

  • Re: Multi Threading Options
    ... If the avatars struct could be modified by any other thread, ... your modifications are so short that releasing the main lock and locking just ... Given that the refresh is timer=based, you could probably eliminate all synchronization ... If it is a UI thread, then while the drawing is happening, the PostMessage ...
    (microsoft.public.vc.mfc)
  • Re: threading - Monitor.Wait/Pulse
    ... thread synchronization is considered a "Bad Thing" since there is no way ... WaitOne/WaitAny/WaitAllmethods of the WaitHandle indicates whether ... don't get with WaitHandles is that it releases the Lock on the Object ... RendezvousDemo demo = new RendezvousDemo; ...
    (microsoft.public.dotnet.general)
  • Re: multithreaded tcp/ip monitoring application
    ... I used the "lock" synchronization mechanism to manage a shared arraylist object. ... So it would be better to have the network i/o code initiate the UI update. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Independent thread fireing events in ATL Service synchronization requirements?
    ... and made my client list a class with synchronization inside ... my guess is that the lock for the COM object ... pointer is not enough and that I would also need to lock ... > the entire loop notifying your objects. ...
    (microsoft.public.vc.atl)
  • Re: How to run tasks with priority?
    ... >> It sounds like you need to use synchronization, ... Only one thread can hold the same lock at the same time. ... private static final Object lock = LockHolder.getLock; ... I think thread with equal priority should have the same chance ...
    (comp.lang.java.help)

Loading