Example #1
0
 def consume(self): 
     while True:
        lock.acquire()
        if not self.b.isEmpty():
            print("Consumer consumed", self.b.pop())
            #time.sleep(random.random())
        lock.release()
Example #2
0
 def consume(self):
     while True:
         lock.acquire()
         if not self.b.isEmpty():
             print("Consumer consumed", self.b.pop())
             #time.sleep(random.random())
         lock.release()
Example #3
0
 def produce(self):  
     while True:
         lock.acquire()
         if not self.b.isFull():
             self.b.push(randint(1,100))
             print ("Producer produced")
             #time.sleep(random.random())
         lock.release()
Example #4
0
 def produce(self):  
     while True:
         lock.acquire()
         if not self.b.isFull():
             self.b.addElement(randint(1, 100000))
         lock.release()
Example #5
0
 def consume(self): 
     while True:
         lock.acquire()
         if not self.b.isEmpty():
             print(self.b.getNextElement())
         lock.release()