954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

static class with list of words

Hi,

I have a program which has to do a lot of lookup.
there are multiple threads running in parallel and all of these threads have to do a lookup on the same list of words.

Currently i'm storing the list of words in a dictionary in each of the threads.

Is there some way i can use a static class which contains the list of all the words so that all the threads can just call a method of this static class and the class returns the result based on lookup.

I want to to this cos i don't want multiple copies of the same data on my memory.

Any suggestions...

arjunpk
Light Poster
46 posts since Jan 2011
Reputation Points: 4
Solved Threads: 2
 

I would also like to know the following.

If i have a static class in my application, does the class get instantiated as soon as the application is started. If so , can i write a static constructor which will load the lookup lists/dictionaries ?

arjunpk
Light Poster
46 posts since Jan 2011
Reputation Points: 4
Solved Threads: 2
 

Yes you can, just declare the class as static and all the methods/properties as static.

A static class is instantiated when the system decides it wants to do it but always before your first use of the class. You don't have to worry about when that happens, it just works (like magic :)).

And yes, you can have a static constructor. You can read about them here

Momerath
Nearly a Senior Poster
3,384 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: