### Question:
ThreadId { public void setError(final int errorCode) { if (this.destroyed) { return; } if (this.lock.tryLock()) { if (this.destroyed) { this.lock.unlock(); return; } if (this.onError != null) { this.onError.onError(this, this.data, errorCode); } } else { this.pendingErrors.add(errorCode); } } ThreadId(final Object data, final OnError onError); Object getData(); Object lock(); void unlock(); void join(); @Override String toString(); void unlockAndDestroy(); void setError(final int errorCode);  }### Answer:
@Test public void testSetError() throws Exception { this.id.setError(100); assertEquals(100, this.errorCode); this.id.lock(); CountDownLatch latch = new CountDownLatch(1); new Thread() { @Override public void run() { ThreadIdTest.this.id.setError(99); latch.countDown(); } }.start(); latch.await(); assertEquals(100, this.errorCode); this.id.unlock(); assertEquals(99, this.errorCode); }