Even if Cipher was thread safe, it would be useless to use it from multiple threads at the same time.
The bytes that you insert and exit Cipher (through the update and finish methods) are a continuous stream. This means that, on the other hand, they must be transmitted in the same order in order to make any sense. This is easiest to do if you have only one thread.
If you use multiple threads, you usually want to call reset between calls - and then you need external synchronization.
PaΕlo Ebermann Aug 05 2018-11-11T00: 00Z
source share