multithreading

TODO:
*) Correct the program in case of exceptions.