Consider the following example code where thread A pushes functions on a queue and thread B executes those when popping from the queue: