• Post Reply Bookmark Topic Watch Topic
  • New Topic

atomic block of code?

 
david zhang
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am coding an application. It has a thread that can be requested to stop any time during its execution.
Inside the thread, there are a few lines of code that should be executed all or none. In another word,
if the thread runs in the middle of this block, then outside interrupt/stop request should not stop the thread
before the block finishes. How can this be accomplished? This block of code has nothing to do with database write.

Thanks,
David
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends on how the "request to stop" is being made. If you're using the deprecated stop() method, then I don't believe there's anything you can do. If you're using interrupt() or a "stop flag" of your own devising, then you simply need to not check these things during the block of statements.
 
david zhang
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest,

Thanks for your advice. I will try.

David
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!