~cpp
import thread, time
g_count = 0
lock = thread.allocate_lock()
def counter(id, count):
global g_count
for i in range(count):
print 'id %s -> %s' % (id, i)
lock.acquire()
g_count = g_count +1
lock.release()
for i in range(5):
thread.start_new_thread(counter,(i,5))
time.sleep(3)
print 'Total Counter =', g_count
print 'Exitintg'
~cpp
from Tkinter import *
import time, thread
def CountTime():
global i
i=0
count=0
while count<80:
text.insert(1.0, i)
text.delete(INSERT)
#text.update()
time.sleep(0.1)
count=count+1
root = Tk()
root.protocol("WM_DELETE_WINDOW", exit)
text=Text(root, height=1)
text.pack()
thread.start_new_thread(CountTime,())
canvas = Canvas(root, width=400, height=300)
canvas.pack()
wall = PhotoImage(file='wall.gif')
canvas.create_image(0, 0, image=wall, anchor=NW)
stop=0
root.mainloop()