473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Synchronized Method for a Collection

I have created a Collection class inherited from the CollectionBase Class.

How would I implement a Synchronized method similar to the Synchronised
method of the HashTable Class.

Thanks,
Fred
Nov 20 '05 #1
2 1155
Fred,

There are a number of ways you COULD do it. HashTable defines a private
class which inherits from Hashtable and overrides the key methods (Add,
Clear etc). It implements the methods by performing the relevant actions in
a SyncLock block. The Synchronised method returns an instance of this
class.

Hope this helps,

Nick Hall

"fred" <fr**@NoSpam.com> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
I have created a Collection class inherited from the CollectionBase Class.

How would I implement a Synchronized method similar to the Synchronised
method of the HashTable Class.

Thanks,
Fred

Nov 20 '05 #2
Thanks Nick.
"Nick Hall" <ni***@aslan.nospam.co.uk> wrote in message
news:uf****************@TK2MSFTNGP09.phx.gbl...
Fred,

There are a number of ways you COULD do it. HashTable defines a private
class which inherits from Hashtable and overrides the key methods (Add,
Clear etc). It implements the methods by performing the relevant actions in a SyncLock block. The Synchronised method returns an instance of this
class.

Hope this helps,

Nick Hall

"fred" <fr**@NoSpam.com> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
I have created a Collection class inherited from the CollectionBase Class.
How would I implement a Synchronized method similar to the Synchronised
method of the HashTable Class.

Thanks,
Fred


Nov 20 '05 #3

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

Similar topics

2
by: Frank | last post by:
Hi, In the javadocs regarding many of the java.util classes, it states that the classes are not synchronized, and suggest using the Collections.synchronizedX(...) methods for getting...
5
by: Max Ischenko | last post by:
Hi, I wrote simple implementation of the "synchronized" methods (a-la Java), could you please check if it is OK: def synchronized(method): """ Guards method execution, similar to Java's...
4
by: chrisben | last post by:
Hi I often use Queue.Synchronized method to create a queue for multithread writing. I also know I could use SyncRoot and lock to write Queue. Could anyone here please explain to me the pros and...
8
by: ASP.Net programmer | last post by:
Hi, I have a few methods in a class that I want to synchronize (make sure they can't be used at the same time by multiple threads). As a Java programmer I just do this: public synchronized...
2
by: Urs Vogel | last post by:
Hi I'm using static, synchronized Hashtables: static Hashtable _htDiags = new Hashtable(); static Hashtable htDiags = Hashtable.Synchronized(_htDiags); I'm not totally sure, if this...
4
by: nhmark64 | last post by:
Hi, Does System.Collections.Generic.Queue not have a Synchronized method because it is already in effect synchronized, or is the Synchronized functionality missing from...
7
by: Alan Wang | last post by:
Hi there, How can I create synchronized method in vb.net like synchronized method in Java? Thanks in advanced Alan
28
by: Michael Primeaux | last post by:
What is the recommended pattern for implementing a synchronized (thread-safe) class that inherits from Collection<T>? For example, I want to implement a SyncRoot property . I do see where I can...
2
by: semedao | last post by:
Hi, what is the best way to Synchronized threads on classes that use or inherit from Generics ? (Dictionary for example) Thanks. (and where is the *Class*.Synchronized method for them ?)
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
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...
0
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,...

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.