<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <pre style="" class="lang-pascal prettyprint prettyprinted"><code><span class="pln">Hi guys

A number of threads need to access an object, but no more than three threads must access simultaneously.

Thats a job for a semaphore someone said. </span></code><code><span class="pln"><code><span class="pln">I understand </span></code>that under Delphi and Windows something like this could be used:

FSemaphoreHandle </span><span class="pun">:=</span><span class="pln"> CreateSemaphore</span><span class="pun">(</span><span class="kwd">nil</span><span class="pun">,</span><span class="pln"> 3</span><span class="pun">,</span><span class="pln"> 3</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">nil</span><span class="pun">);
</span></code><code><span class="pln">WaitForSingleObject</span><span class="pun">(</span><span class="pln">FSemaphoreHandle</span><span class="pun">,</span><span class="pln"> </span><span class="pun"><</span><span class="pln">timeout</span><span class="pun">>);</span></code>

How to do that under Lazarus and Linux? 

I have found TThreadManager with its SemaphoreInit and SemaphoreWait etc. But how to use it, especially how do you specify the number of threads that can access the object?

Using 32 bit Lazarus trunk and FPC trunk.
</pre>
  </body>
</html>