Question: There is an AIDL interface

```
interface ISimpleService {
    void register(in ISomeCallback callback);
    void deregister(in ISomeCallback callback);
}

```

Callback is defined this way

```
interface ISomeCallback {
    void notify(int event);
}

```

In the `register` and `deregister` implementation callbacks are put in the `LinkedBlockingQueue` through `add` and `remove` methods. The issue is that the same object with the same hash passed through AIDL has different hash after AIDL (inside register and deregister methods) and it is treated as different instance, so that the objects are never removed from the queue.

How can I check during removal that the object is same as one that is in the queue without adding keys (I am limited in changing interface)?

Answer: 
You could try override `hashCode()` and `equals()` methods of your `ISomeCallback` implementations. By that you can decide which objects are the same.
You can use RemoteCallbackList<ISomeCallback> from Android api for storing your callback. In your example, it would looks like this:

```
public class SimpleService extends ISimpleService.Stub {
    RemoteCallbackList<ISomeCallback> mLists = 
        new RemoteCallbackList<ISomeCallback>();
    ...
    public void register(ISomeCallback callback) {
        mLists.register(callback);
    }
    public void unregister(ISomeCallback callback) {
        mLists.unregister(callback);
    }
}

```

The class is already Thread-safe one, so i think it will work flawlessly on your problems. Please noet that it is based on your reference, not the hashcode. If you pass different objects with hashcode it won't be treated as same object.

Reference: <http://developer.android.com/reference/android/os/RemoteCallbackList.html>