Join() method in thread class is used while implementing multi-threading. The join method will allow one thread to wait until another thread completes its execution.
As you are using single thread, so there is no need to use the join method.
Eliminate the join method so that you will not get the error and the output for your program after removing the join method is:
m1
m2
r1
r2