Thread Safety for Imgproc.threshold on Java

I have the problem that the function

Imgproc.threshold(gray, gray, 100, 255, Imgproc.THRESH_BINARY);

works, but not

Imgproc.threshold(gray, gray, a, b, Imgproc.THRESH_BINARY);

a and b from type int with the corresponding values.

The application takes place in an extra thread and in the one with objects (not static ones).

Can anyone give me an approach?
SysLogs all show the correct contents.

I remove my question, but with in extra Mat works. Sorry.