using the multiprocessing module using the threading module processes and threading |||with the advent of multicore processors as the norm rather than the exceptionit is more tempting and more practical than ever before to want to spread the processing load so as to get the most out of all the available cores there are two main approaches to spreading the workload one is to use multiple processes and the other is to use multiple threads this shows how to use both approaches using multiple processesthat isrunning separate programshas the advantage that each process runs independently this leaves all the burden of handling concurrency to the underlying operating system the disadvantage is that communication and data sharing between the invoking program and the separate processes it invokes can be inconvenient on unix systems this can be solved by using the exec and fork paradigmbut for cross-platform programs other solutions must be used the simplestand the one shown hereis for the invoking program to feed data to the processes it runs and leave them to produce their output independently more flexible approach that greatly simplifies two-way communication is to use networking of coursein many situations such communication isn' needed--we just need to run one or more other programs from one orchestrating program an alternative to handing off work to independent processes is to create threaded program that distributes work to independent threads of execution this has the advantage that we can communicate simply by sharing data (providing we ensure that shared data is accessed only by one thread at time)but leaves the burden of managing concurrency squarely with the programmer python provides good support for creating threaded programsminimizing the work that we must do nonethelessmultithreaded programs are inherently more complex than single-threaded programs and require much more care in their creation and maintenance in this first section we will create two small programs the first program is invoked by the user and the second program is invoked by the first pro