In a multi-threaded Java application, if I want to identify the instructions where the context switch from one thread to another happens, what is the best approach? Instrumenting every instruction to identify what thread is executing the instruction will give a close approximation. For example, if the switch happens after the instrumentation is executed and before the actual instr. is executed, then the result will be imprecise.
Is there a way to precisely identify the context switch location (which will be different for different runs) in Java?
What is the most cost effective of identifying this?
Short answer to your question is You can not do it in java
.It is the resposibility of JVM to switch the context based on underlying operating system and memory model.
http://en.wikipedia.org/wiki/Thread_(computing)
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