Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Using threads in a web service

Using threads in a web service

Scheduled Pinned Locked Moved ASP.NET
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    totig
    wrote on last edited by
    #1

    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!

    C 1 Reply Last reply
    0
    • T totig

      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!

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • C Colin Angus Mackay

        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

        T Offline
        T Offline
        totig
        wrote on last edited by
        #3

        Thank you for the answer.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups