Message3920

Author gunter.bach
Recipients gunter.bach
Date 2008-12-15.13:30:12
SpamBayes Score 5.6629764e-05
Marked as misclassified No
Message-id <1229347813.14.0.000473318889901.issue1203@psf.upfronthosting.co.za>
In-reply-to
Content
This naive program creates 10000 threads. More than 2000 of them are not
executed completely:

-----
import thread, time

cnt_a = cnt_b = 0
def test():
    global cnt_a, cnt_b
    time.sleep(1)
    cnt_a += 1
    time.sleep(1)
    cnt_b += 1

i = 10000
while i:
    i -= 1
    thread.start_new_thread(test, ())

time.sleep(100)
print cnt_a, cnt_b
----

The program prints two different numbers not equal to 10000.

Tested on Linux, Jython2.1, java1.5.0 and Windows, Jython2.5a3, jdk1.6.0_01.
History
Date User Action Args
2008-12-15 13:30:13gunter.bachsetrecipients: + gunter.bach
2008-12-15 13:30:13gunter.bachsetmessageid: <1229347813.14.0.000473318889901.issue1203@psf.upfronthosting.co.za>
2008-12-15 13:30:13gunter.bachlinkissue1203 messages
2008-12-15 13:30:12gunter.bachcreate