title: Event trigger - Best practices
body: <p>My program collects data from various sensors and whenever there is something wrong with the sensor reading, then I have to send an email to alert the user. </p>
  
  <p>For this, I have assigned a variable SEND_MSG to trigger the email send event. Whenever there is something off with the reading, I set SEND_MSG to 999 and another thread, which loops and checks this variable triggers the send email process. Read/Write operation of the SEND_MSG occurs inside a lock statement. </p>
  
  <p>Is there a better way to do this?</p>
  
  <p>Thank you.</p>