Fixed getPolicy() method to make it thread-safe.
Fixed getPolicy() method to make it thread-safe.

(cherry picked from commit 8910508b838363ce4f721e5b463cd04cfd225a1a)

opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv,opencv/opencv