futures in python from concurrent futures import processpoolexecutor print('setting up the threadpoolexecutor'pool processpoolexecutor( print('submitting the worker to the pool'future pool submit(worker' 'print('obtained reference to the future object'future print('future result():'future result()print('done'the output from this program is very similar to the last onesetting up the threadpoolexecutor submitting the worker to the pool obtained reference to the future object <future at state=runningaaaaaaaaaafuture result() done the only difference is that in this particular run the message starting 'obtained is printed out before any of the ' ' are printedthis may be due to the fact that process initially takes longer to set up than thread running multiple futures both the threadpoolexecutor and the processpoolexecutor can be configured to support multiple threads/processes via the pool each task that is submitted to the pool will then run within separate thread/process if more tasks are submitted than there are threads/processes availablethen the submitted task will wait for the first available thread/process and then be executed this can act as way of managing the amount of concurrent work being done for examplein the following examplethe worker(function is submitted to the pool four timesbut the pool is configured to use threads thus the fourth worker will need to wait until one of the first three completes before it is able to executefrom concurrent futures import threadpoolexecutor print('starting 'pool threadpoolexecutor( future pool submit(worker' 'future pool submit(worker' 'future pool submit(worker' 'future pool submit(worker' 'print('\nfuture result():'future result()print('all done'