'Is IBinder.transact() thread-safe?

Context to the problem:
I am creating a client that binds to a service that uses a custom RPC (i.e. it doesn't user Messenger or AIDL). So, I need to interact directly with a IBinder calling transact. From reading the documentation, transact is synchronous and, in my case, the call takes a couple hundred milliseconds. So to not block the main thread, I created a thread pool and execute it using the thread pool. However, going through the aforementioned documentation, I couldn't find anywhere that stated if the transact method is thread safe.

Question: can transact be called by multiple threads or do I have to guard it with a synchronize block?

I am aware that Binder.onTransact can be called (by the os) by multiple threads but that doesn't say anything about transact.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source