{
boolean successful = false;
try
{
AtomicTransaction atomicTransaction = new AtomicTransaction();
try
{
atomicTransaction.begin();
try
{
int d = Math.abs(_random.nextInt() % 10) + 1;
int x0 = Math.abs(_random.nextInt() % _matrixWidth);
int y0 = Math.abs(_random.nextInt() % _matrixHeight);
int x1 = Math.abs(_random.nextInt() % _matrixWidth);
int y1 = Math.abs(_random.nextInt() % _matrixHeight);
IntHolder location0Value = new IntHolder();
IntHolder location1Value = new IntHolder();
Control control = OTS.current().get_control();
_matrix.get_value(x0, y0, location0Value, control);
_matrix.get_value(x1, y1, location1Value, control);
_matrix.set_value(x0, y0, location1Value.value + d, control);
_matrix.set_value(x1, y1, location0Value.value - d, control);
successful = (x0 != x1) || (y0 != y1);
}
catch (InvocationException invocationException)
{
if (invocationException.myreason != Reason.ReasonConcurrencyControl)
{
throw invocationException;
}
}
if (successful)
{
atomicTransaction.commit(true);
}
else
{
atomicTransaction.rollback();
}
}
catch (Exception exception)
{
if (atomicTransaction.get_status() == Status.StatusActive)
{
atomicTransaction.rollback();
}
throw exception;
}
}