python locks shared_data shareddata(def reader()while trueprint(shared_data read_value()def updater()while trueshared_data change_value(print('starting' thread(target=readert thread(target=updatert start( start(print('done'the output from this isstarting read_value acquiring lock read_value releasing lock read_value acquiring lock read_value releasing lock done change_value acquiring lock change_value lock released change_value acquiring lock change_value lock released change_value acquiring lock change_value lock released change_value acquiring lock change_value lock released lock objects can only be acquired onceif thread attempts to acquire lock on the same lock object more than once then runtimeerror is thrown if it is necessary to re-acquire lock on lock object then the threading rlock class should be used this is re-entrant lock and allows the same thread (or processto acquire lock multiple times the code must however release the lock as many times as it has acquired it