python conditions from threading import threadconditioncurrentthread from time import sleep from random import randint class dataresourcedef __init__(self)print('dataresource initialising the empty data'self data none print('dataresource setting up the condition object'self condition condition(def consumer(self)"""wait for the condition and use the resource""print('dataresource starting consumer method in'currentthread(namewith self conditionself condition wait(print('dataresource resource is available to'currentthread(nameprint('dataresource data read in'currentthread(name':'self datadef producer(self)"""set up the resource to be used by the consumer""print('dataresource starting producer method'with self conditionprint('dataresource producer setting data'self data randint( print('dataresource producer notifying all waiting threads'self condition notifyall(print('main starting'print('main creating the dataresource object'resource dataresource(print('main create the consumer threads' thread(target=resource consumerc name 'consumer thread(target=resource consumerc name 'consumer print('main create the producer thread' thread(target=resource producerprint('main starting consumer threads' start( start(sleep( print('main starting producer thread' start(print('main done'