WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-19-2008, 02:10 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The problem is that your script does not wait for the threads to complete before exiting. I've modified your script to use the more advanced threading module. It will also wait for all the threads to complete before exiting. Here is the code:
Code:
import threading

#Create mutex for printing
printLock = threading.Lock()

def countingThread(id, maxVal):
	global printLock
	for i in range(maxVal):
		printLock.acquire()
		print "Thread ", id, ": ", i
		printLock.release()

threads = []
for i in range(5):
	#Create and start the threads
	t = threading.Thread(target=countingThread, args=(i, 50))
	t.start()
	
	#Save thread object to list
	threads.append(t)

#Wait for threads to complete
for t in threads:
	t.join()
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Vizard won't run wouters Vizard 5 02-05-2008 11:12 AM
Fall 2007 release of Vizard R3 3 D Announcements 0 10-15-2007 04:50 PM
McAfee Privacy Service 8.1 causes Vizard not to run mspusch Vizard 0 03-01-2007 08:24 PM
Matlab and Vizard brystewa Vizard 1 09-18-2006 03:11 PM
wxPython with Vizard farshizzo Vizard 18 09-29-2005 08:49 AM


All times are GMT -7. The time now is 01:04 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC