Skip to main content
Jul 12, 2022 3:32 PM UTC
Solved

Making service wait until it's finished to start again

I am creating an app that reads bit values from an opc and calculates an state based on which ones are active. Problem is sometimes they change in pairs at the same time and the subscription that is listening to that runs twice and gives two simultaneous results. Is there any way to make the service wait untils it's finished before running again? It is currently written in java using the thingworx extension library and it's already synchronous.

 

Thank you

AViñetaAnswer
Jul 13, 2022 9:46 AM UTC

We managed to solve it. using the synchronized word in java already makes that happen. If it still happens "simultaneously" is most likely because it runs too fast. I added a Thread.sleep for 250 milis and worked like a charm. Hope it helps you!

2 replies

Jul 13, 2022 5:47 AM UTC

Looking for the same issue. Bumped into your thread. Thanks for creating it. Looking forward for solution.

AViñetaAuthorAnswer
Jul 13, 2022 9:46 AM UTC

We managed to solve it. using the synchronized word in java already makes that happen. If it still happens "simultaneously" is most likely because it runs too fast. I added a Thread.sleep for 250 milis and worked like a charm. Hope it helps you!