Skip to main content
1-Visitor
July 12, 2022
Solved

Making service wait until it's finished to start again

  • July 12, 2022
  • 1 reply
  • 1379 views

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

Best answer by AViñeta

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!

1 reply

1-Visitor
July 13, 2022

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

AViñeta1-VisitorAuthorAnswer
1-Visitor
July 13, 2022

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!