Hello,

Is following psudo code sequecne correct?

Class SearchProvider
{

*static Object myLock = new Object();*

Hits Search(..)
{

*lock(myLock)*
{

IndexSearcher searcher = new IndexSearcher(dir);
return searcher.search(....);

}


}

}

Hear myLock is the static object in the SearchProvider class.
I use search as follow.

SearchProvider s = new SearchProvider();
s.Search(..);

If i only need index search and dont need index update then is *lock(myLock)
statement required?*
**
why do we need *lock(myLock)? *

I have seen such code sequence in many examples but i am not understanding
why it is required. Please provide comment on this.

Thanks,
Hardik

Reply via email to