Can a thread hold multiple semaphore keys?

Can a thread use multiple semaphore keys?

semaphore a=new(2);

module testbench();
 
  initial begin: thread_1
    #10;
    a.get(1);
    $display($time,"thread 1 got the key");
    a.put(1);
    $display($time,"thread 1 put the key");
  end
  
  initial begin: thread_2
    a.get(2);
    $display($time,"thread 2 got the key");
    a.get(1);
    a.put(1);
  end

endmodule: testbench

OUTPUT:
0 Thread 2 got the key.

if thread 2 happens in time 0 why isn’t the taken keys are not used in the thread 1 even if the thread 2 put both keys into the semaphore

In reply to Thobiyas:

Each instance of a semaphore holds a count of keys. A thread can add or subtract from that count; it doesn’t hold anything.

Thread_2 hangs because it tries to get(1) a third semaphore key which never gets added. Perhaps you meant that to be put(1) instead? Thread_1 hangs because the keycount is 0 at time 10.

In reply to dave_59:

Yeah I get it… so the numbers within the get or put method denotes no of keys (or we can say) how many keys the method going to get or put…

Thank you!