Reputation: 615
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?
Upvotes: 1
Views: 339
Reputation: 1920
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.
Upvotes: 0