Semaphore question

Justin Sheehy justin at iago.org
Thu Jan 31 05:02:08 CET 2002


"MDK" <mdk at mdk.com> writes:

> 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.

Just use a Queue.Queue() instead.  It exists to solve this problem,
and it does so very well.

-Justin

 





More information about the Python-list mailing list