1 Reply Latest reply: Nov 3, 2012 11:29 PM by DrClap RSS

    What is the lowest overhead way to limit executing one section of code to 4

    DavidThi808
      In a single app we need to limit executing a section of code to 4 threads. This section is not the start/end of the thread, it is a section of code inside the thread.

      So what is the most light-weight way to do this when all threads are in a single app? Semaphore?

      Background: We are changing our licensing model to allow a maximum of N (4 in this example) threads calling our library consecutively. Because we're a library, not a server, we don't control the thread usage (like databases can). In the case of a web app, the calling app also doesn't control the number of threads and so we need to pause thread 5 calling us until one the first 4 exit that code.