#-*- coding:utf8 -*-from multiprocessing import Process,sharedctypesfrom time import sleepclass Work: def __init__(self): self.Process = Process self.num = sharedctypes.Value("i",1) def producter(self): self.add() def consumer(self): self.add() def add(self): self.num.value += 1 def start(self): self.Process(target=self.producter).start() self.Process(target=self.consumer).start() sleep(1) print self.num.valueif __name__ == '__main__': W = Work() W.start()