Threading

Chris Angelico rosuav at gmail.com
Fri Jan 24 17:06:53 EST 2020


On Sat, Jan 25, 2020 at 9:05 AM Matt <matt.mailinglists at gmail.com> wrote:
>
> Created this example and it runs.
>
> import time
> import threading
>
> big_list = []
>
> for i in range(1, 200):
>     big_list.append(i)
>
> def start_test():
>     while big_list: #is this????
>         list_item = big_list.pop() #and this thread safe????
>         print list_item, port
>         time.sleep(1)
>
> print "Creating Threads..."
>
> port = 80
> for i in range(1, 10):
>     t = threading.Thread(target=start_test)
>     t.start()
>
> print "Waiting on Threads..."
>
> t.join()
>
> print "Finished..."
>

Please don't top-post. Also, switch to a Python 3 interpreter before
you end up filling your code with Py2isms and make your job harder
later.

ChrisA


More information about the Python-list mailing list