S
siddharthkhare
Hi All,
I have a block of code. I don't want more than five threads to enter
this block simultaneously...
Some thing like this
lock(MyObject)
{
....do work here.
}
so this will allow only one thread to enter at once .
what i want is a effect like
lock(MyObject1) || lock(MyObject2) || lock(MyObject3) ||
lock(MyObject4) || lock(MyObject5)
{
....do work here.
}
This obviously does not compile.
so how can i do this .
1)Do i have to write my own thread pool and limit the number of threads
to 5?
2)Can i do it using using the thread pool class provided in .net ?
3)Can i do it with without using any of the thread Pool class (.net
threadPool or custom thread pool class ) instead use some specific type
of lock to achieve this.
...may be i can maintain some counter and make thread sleep for some
time ..but...I am thinking there might be a better and more clean
solution than this one...
Appreciate any ideas...
Thanks
Sidd
I have a block of code. I don't want more than five threads to enter
this block simultaneously...
Some thing like this
lock(MyObject)
{
....do work here.
}
so this will allow only one thread to enter at once .
what i want is a effect like
lock(MyObject1) || lock(MyObject2) || lock(MyObject3) ||
lock(MyObject4) || lock(MyObject5)
{
....do work here.
}
This obviously does not compile.
so how can i do this .
1)Do i have to write my own thread pool and limit the number of threads
to 5?
2)Can i do it using using the thread pool class provided in .net ?
3)Can i do it with without using any of the thread Pool class (.net
threadPool or custom thread pool class ) instead use some specific type
of lock to achieve this.
...may be i can maintain some counter and make thread sleep for some
time ..but...I am thinking there might be a better and more clean
solution than this one...
Appreciate any ideas...
Thanks
Sidd