Java micro-library for writing & testing concurrent code
Avoid JMock Finaliser Problems
The default threading policy for a JMock Mockery warns if the mockery is being used by multiple threads. The SingleThreadedPolicy will output the following.
2012-05-31 07:35:35 ERROR Finalizer [Console$Logger] - the Mockery is not thread-safe: use a Synchroniser to ensure thread safety
If you really need multi-threaded access to the mockery, it’s a straight forward fix to swap the policy out. As in the log line above though, sometimes the JVM’s finaliser thread sticks it’s oar in and confuses the SingleThreadedPolicy.
To get rid of this, you can set a custom threading policy that performs the same check as the default, just not when the finaliser thread is involved.