Semaphore question

MDK mdk at mdk.com
Wed Jan 30 16:55:41 EST 2002


I have two threads that share a list Data[].

One thread appends stuff to the list.

The other thread reads the first item if one exists and then deletes the
first item.

My understanding about multithreading is that you need to be careful about
how threads share such common objects.  To handle this it appears that one
uses a Semaphore.

I have examined the example in the documentation but it does not make sense
to me.

Could someone give me a clear example of how to use Semaphore so that the
threads properly acquire and release the Data list?

Thank you.





More information about the Python-list mailing list