org.jmock.lib.concurrent

## Class Synchroniser

- java.lang.Object
- - org.jmock.lib.concurrent.Synchroniser

All Implemented Interfaces:
  ThreadingPolicy

    public class Synchroniser
    extends Object
    implements ThreadingPolicy

A ThreadingPolicy that makes the Mockery thread-safe and helps tests synchronise with background threads.

Author:
  Nat Pryce

### Constructor Summary

Constructors
Constructor and Description
`Synchroniser()`

### Method Summary

Methods
`Invokable` `synchroniseAccessTo(Invokable mockObject)`
`void` `waitUntil(org.jmock.internal.StatePredicate p)` Waits for a StatePredicate to become active.
`void` `waitUntil(org.jmock.internal.StatePredicate p, long timeoutMs)` Waits up to a timeout for a StatePredicate to become active.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### Synchroniser

    public Synchroniser()

### Method Detail

#### waitUntil

    public void waitUntil(org.jmock.internal.StatePredicate p)
                   throws InterruptedException

Waits for a StatePredicate to become active. Warning: this will wait forever unless the test itself has a timeout.

Parameters:
  `p` - the StatePredicate to wait for
Throws:
  `InterruptedException`

#### waitUntil

    public void waitUntil(org.jmock.internal.StatePredicate p,
                 long timeoutMs)
                   throws InterruptedException

Waits up to a timeout for a StatePredicate to become active. Fails the test if the timeout expires.

Parameters:
  `p` - the StatePredicate to wait for
  `timeoutMs` - the timeout in milliseconds
Throws:
  `InterruptedException`

#### synchroniseAccessTo

    public Invokable synchroniseAccessTo(Invokable mockObject)

Specified by:
  `synchroniseAccessTo` in interface `ThreadingPolicy`