transformed non-recursive pthread mutex to recursive one

for the new UMat class we need a recursive mutex.