Thanks for the advice.Is there any other idea for the problem.Actually for every 1000 millisecond i get the data from external source .It may well "work" as long as your system is lightly loaded and allows your two threads to run most of the time, but it's certianly not a robust design