Pefko
Pefko

Reputation: 3

Outputting variable from one thread to other

I have a thread that has an infinite loop running, updating a variable constantly. How can I access the live value of that variable in an another thread/outside of the thread (without being in an infinite loop)?

Upvotes: 0

Views: 828

Answers (1)

Bauyrzhan Ospan
Bauyrzhan Ospan

Reputation: 428

the best way to do it is to use global variables. But, you need to be aware of the lock conditions when threads are reading and writing to one variable at once.

There is a good manual for example.

Upvotes: 0

Related Questions