1

In my j2me app I have an array of double data type containing 5 coordinates value. This array is inside the thread to continuously check whether the same values is given by GPS.

Once it get correct match, I want to pause the thread then remove match found value from thread and resume the thread. I want this should be happen till array contains coordinates values. Once array got empty I want to pause the thread till it get new value, Once again when array gets values it should start again.

How should I implement this logic in code?

gnat
  • 6,213
  • 108
  • 53
  • 73
Rahul More
  • 615
  • 3
  • 13
  • 41

1 Answers1

0

If it was me, I wouldn't bother putting the Thread into pause. I'd just have it running all the time.

while (true) {

 for (coordinate in arrayOfCoordinates) {
  if (checkLocation(coordinate)) removeFromArray(coordinate);
 }

try { Thread.sleep(5000); } catch (Exception e) {}

}

I don't see any reason putting the thread into pause, when it's only making such a small check you describe.

mr_lou
  • 1,910
  • 2
  • 14
  • 26
  • To remove match found coordinates values from array I want to pause the thread.... once respective value get removed then resume thread running.. – Rahul More Mar 24 '13 at 11:13
  • No need to pause the thread for that. Removing entries from an array takes only a few milliseconds, if not less. – mr_lou Mar 24 '13 at 13:51