Saw the term 'thread-hopping' while reading some documentation, I didn't find a good description after a few minutes of googling. So as per title, what is thread hopping and when is it necessary?
Context - I came across the term while reading source code https://github.com/Netflix/RxJava/blob/78c250bf4429501db4e285a4840f0b934797d5a7/rxjava-core/src/main/java/rx/schedulers/ExecutorScheduler.java#L37
I guess it is the phenomenon of having a lot of tasks/jobs/runnables being executed by an executor service which is backed by a pool of threads with unknown internal queueing mechanisms.
In such cases there might not be a way to predict which job is running in which of the pooled threads and special attention has to be paid to communication between threads, ownership, ..
In a way the execution of tasks hops from thread to thread. This is not strictly necessary, one could implement affinity to threads, but it's often difficult to avoid, so one has to be careful.
I got my knowledge about this from googling for some time. Therefore I make it community wiki.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With