title: Context switching in Java
body: <p>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.</p>
  
  <ul>
  <li><p>Is there a way to precisely identify the context switch location (which will be different for different runs) in Java? </p></li>
  <li><p>What is the most cost effective of identifying this? </p></li>
  </ul>