Patent ID: 8327378

Claim:
A method of stopping a multi-threaded application, wherein the multi-threaded application comprises a plurality of threads performing a plurality of tasks, the method comprising: maintaining a set of work permits, wherein each of the plurality of threads is required to acquire one of the set of work permits before performing one of the plurality of tasks and to release the acquired work permit after completion of performance of the task; allowing the plurality of threads to acquire a first subset of work permits and a second subset of work permits, wherein the first subset of work permits and the second subset of work permits are contained in the set of work permits; receiving after the allowing, at a time instance, a stop notification indicating that the multi-threaded application is to be stopped, wherein all of the first subset of work permits are released by the time instance and none of the second subset of work permits is released by the time instance; and after the time instance and in response to receiving of the stop notification: denying the plurality of threads from acquiring any additional work permit such that none of the plurality of threads can start performance of any new tasks; waiting for all of the second subset of work permits to be released; and stopping the multi-threaded application only when all of the set of work permits, including the second subset of work permits, are released by the plurality of threads.