473,804 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Collection and synchronisation .

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
Jul 21 '05 #1
3 1569
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


Jul 21 '05 #2
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

Jul 21 '05 #3
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



Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
1871
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...
0
1443
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 -...
0
1136
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...
3
381
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); }
9
1493
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...
0
1044
by: tbb | last post by:
Hi is it possible to do the synchronisation of the briefcase programmatically? Greets tim
1
1677
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
19
2327
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?
4
3084
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.
0
9715
marktang
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...
1
10354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10097
tracyyun
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...
0
9175
agi2029
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...
1
7642
isladogs
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...
0
6867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4313
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
2
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.