threading id generator ?
Alan Kennedy
alanmk at hotmail.com
Thu Feb 19 09:52:00 EST 2004
[Andrea Manzini]
> I'm a python newbie with a little problem; my need is to share an
> incrementing counter between threads; i.e. every time I create a
> new thread (which handle a single tcp/ip connection), I must assign
> an unique numeric ID to it, without reuse old numbers... In example:
>
> thread-1 id: 1
> thread-2 id: 2
> thread-3 id: 3
> thread-100 id: 100
> thread-n id: n
>
> which locking semantic I must use to implement a shared generator
> in a thread ?
This came up about a month ago. Group-Googling for ("shared generator"
and "multiple threads") gives useful results.
http://groups.google.com/groups?hl=en&lr=&ie=ISO-8859-1&q=%22shared+generator%22+%22multiple+threads%22&meta=group%3Dcomp.lang.python.*
regards,
--
alan kennedy
------------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan: http://xhaus.com/contact/alan
More information about the Python-list
mailing list