Using threads in a web service
-
Hi, I have a question. If I create a webservice that happens to have two threads for seperate tasks - when I use lock, I understand that the 1 thread will not run until the other finishes its task that is locked. My question then, does this lock per request, or for the entire application? I am just worried what would happen if 3 requests came in at the same time. Thanks in advance!
-
Hi, I have a question. If I create a webservice that happens to have two threads for seperate tasks - when I use lock, I understand that the 1 thread will not run until the other finishes its task that is locked. My question then, does this lock per request, or for the entire application? I am just worried what would happen if 3 requests came in at the same time. Thanks in advance!
toticow wrote:
when I use lock, I understand that the 1 thread will not run until the other finishes its task that is locked
Incorrect. It means that the second thread cannot enter any section that uses the same object for the lock. Both threads can continue running simultaneously even if one is inside a locked section.
Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." My website
-
toticow wrote:
when I use lock, I understand that the 1 thread will not run until the other finishes its task that is locked
Incorrect. It means that the second thread cannot enter any section that uses the same object for the lock. Both threads can continue running simultaneously even if one is inside a locked section.
Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." My website