is += in python thread safe?

前端 未结 2 1471
长发绾君心
长发绾君心 2021-02-09 01:31
globalnum = 0
n = 1

class T( threading.Thread ):
  def run( self ):
    global globalnum
    globalnum += n

for _ in xrange( 0, 999 ):
  t = T()
  t.start()

print glo         


        
2条回答
提交回复
热议问题