I am not sure I understand the multi-threaded environment impact. The operate command is atomic and will either succeed or roll back. The caller can specify the value to increment by (not the value to set it to).
Regarding the initial check, I think it can be done with an Expression that would evaluate based on the value in the counter.
You should be able to do this with a UDF as well of course, but I think an operate command and an Expression should be enough and would be much more efficient (lightweight).