Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending SMS after 5 minuts intervals...  RSS feed

 
Sanket L Shah
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I am developing one application using Threads..
I haven't worked in Thread before...

If event A is occur, then after every 5 minutes I want to send one SMS.
but if event B is occur after some time then SMS should not be sent...

I want only one thread for sending SMS... means if event A has occurred and if again A event occur then no other thread should start for sending SMS.. only the old one should
keep running...

Hope you people have got my question...

Thanks a lot...


 
Ireneusz Kordal
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Look at ScheduledThreadPoolExecutor -> http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html
It allows you to schedule task to execute after given delay, and then cancel this task if necesarry.
 
Sanket L Shah
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Ireneusz Kordal !!!

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!