Hi List,
I have a question on collection synchronisation . For example I have an
ArrayList called myList and the code is like this:
lock (myList.SyncRoo t)
{
// do update on myList
Monitor.PulseAl l(myList.SyncRo ot);
}
Question, do I need to do Monitor.PulseAl l() in here? Because the code above
is potentially accessed by several thread.
Thanks,
Wes 3 1568
Not sure what your doing, but you don't need pulse here. All other threads
will block on lock (if they lock the same syncRoot instance) and be release
in turn as lock is released. hth
--
William Stacey, MVP
"wesley" <we*@inthemix.c om.au> wrote in message
news:uh******** ******@TK2MSFTN GP10.phx.gbl... Hi List,
I have a question on collection synchronisation . For example I have an ArrayList called myList and the code is like this:
lock (myList.SyncRoo t) { // do update on myList Monitor.PulseAl l(myList.SyncRo ot); }
Question, do I need to do Monitor.PulseAl l() in here? Because the code
above is potentially accessed by several thread.
Thanks,
Wes
Thanks,
I got confused a bit with the Monitor.Pulse/PulseAll doc because it says
here:
"The thread that currently owns the lock on the specified object invokes
this method to signal all threads waiting to acquire the lock on the object.
After the signal is sent, the waiting threads are moved to the ready queue.
When the thread that invoked PulseAll releases the lock, the next thread in
the ready queue acquires the lock."
So I thought I need to do Pulse so the other thread waiting can try to get
the lock.
Thanks,
wes Not sure what your doing, but you don't need pulse here. All other
threads will block on lock (if they lock the same syncRoot instance) and be
release in turn as lock is released. hth
-- William Stacey, MVP
Hi List,
I have a question on collection synchronisation . For example I have an ArrayList called myList and the code is like this:
lock (myList.SyncRoo t) { // do update on myList Monitor.PulseAl l(myList.SyncRo ot); }
Question, do I need to do Monitor.PulseAl l() in here? Because the code above is potentially accessed by several thread.
Thanks,
Wes
That is when your doing fancier stuff with monitor and waits, etc (i.e.
readers and writers). Normally you can just use "lock()" for many things.
lock actualy is sugar for Monitor.
--
William Stacey, MVP
"wesley" <we*@inthemix.c om.au> wrote in message
news:Of******** ******@TK2MSFTN GP11.phx.gbl... Thanks,
I got confused a bit with the Monitor.Pulse/PulseAll doc because it says here: "The thread that currently owns the lock on the specified object invokes this method to signal all threads waiting to acquire the lock on the
object. After the signal is sent, the waiting threads are moved to the ready
queue. When the thread that invoked PulseAll releases the lock, the next thread
in the ready queue acquires the lock."
So I thought I need to do Pulse so the other thread waiting can try to get the lock.
Thanks,
wes
Not sure what your doing, but you don't need pulse here. All other threads will block on lock (if they lock the same syncRoot instance) and be release in turn as lock is released. hth
-- William Stacey, MVP
Hi List,
I have a question on collection synchronisation . For example I have an ArrayList called myList and the code is like this:
lock (myList.SyncRoo t) { // do update on myList Monitor.PulseAl l(myList.SyncRo ot); }
Question, do I need to do Monitor.PulseAl l() in here? Because the code above is potentially accessed by several thread.
Thanks,
Wes
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dumbo Liz |
last post by:
Hi
I hold a Design Master for development and synchronise this weekly
with my colleague who enters data and runs reports. This has worked
well for the last 3 months. (He e-mails me a copy and I'm scrupulous
about keeping files in the right place!)
This week Synchronisation failed because "it is not a replicable
database".
I tried compact and repair on the Replica. This produced Conflict
Tables for both my Tables and...
|
by: Tony Epton |
last post by:
I am not quite a newbie in the area of SQL server - more "knows just
enough to be dangerous"
- so please be gentle with me.
Cross posted to several groups - apologies if too far off topic
I have an application that does a lot of massaging of data (insurance
claims) from 3 different data sources to present one set of nice
homogeneous output tables. Uses about 200 various tables and about 300
queries to do the work ( sounds like a mess -...
|
by: Ondine |
last post by:
I have a client running Access 2000 on a desktop (win 98) acting as
the 'server' and a Sony Viaio notebook (win 2000). They are
synchronising and
the data on the laptop is continually getting corrupted. The symptoms
are either relatively minor but very irritating such as a) not finding
records based on the primary key, so all records being displayed or b)
queries showing duplicate records (doubled up) for no reason
whatsoever, when all...
|
by: wesley |
last post by:
Hi List,
I have a question on collection synchronisation. For example I have an
ArrayList called myList and the code is like this:
lock (myList.SyncRoot)
{
// do update on myList
Monitor.PulseAll(myList.SyncRoot);
}
|
by: Dave G |
last post by:
The unexpected problem is this - say, 2 pcs called A and B, both
running my Access program, both arranged in a FE/BE arrangement. There
is an unbound form in the program. When the form opens all the fields
are populated with the required data from the required record. When the
form is closed every field is saved back to the relevant record,
whether it changed or not.
I now realise this is wrong - eg on machine A a name field changes from...
| |
by: tbb |
last post by:
Hi
is it possible to do the synchronisation of the briefcase
programmatically?
Greets tim
|
by: chengsi |
last post by:
Hello,
I am trying to create a button which users can click to activate the synchronisation process within a replica set without having to use the MS Access menus or the Database window (as both of these will be disabled).
Any ideas would be much appreciated.
cheers,
Siwei
|
by: Hapa |
last post by:
Does only reading (never writing) of a variable need thread synchronisation?
Thanks for help?
PS.
Anybody knows a Visual C++ news group?
|
by: sujatha k |
last post by:
I want to create one window service to synchronice my local database with server database.i've done the synchronization process in .net application it is working fine. i copied tat code and put it in windows service OnStart() method. but it is not working. i'm very new to window services. please help me out in this.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |