title: Only one instance of a thread
body: <p>I have some runnable code that is executed through a thread.The thread is executed by multiple pieces of code how can I make sure there is only one thread that executes that runnable at a certain point.</p>
  
  <p>I tried using a boolean value that is true on thread start and becomes false at thread end but that didn't help.</p>
  
  <p>Any ideas?</p>