J
J
Jenki_J2021-01-27 20:56:45
Java
Jenki_J, 2021-01-27 20:56:45

What variables are visible to a thread? What does a thread store in shared memory when volatile?

When using volatile on a single object, all thread-visible objects will be written to the shared memory, not just a single volatile object.
I have no understanding of "objects and variables visible to a thread". Is that all that is used in the run() method? or generally everyone in the class. And if the thread is in a separate file, then what?

Or I have a class and I create a thread inside this class simply through new Thread() { *run method* }
I would be infinitely happy if someone explained to me in an accessible way what exactly the thread sees and will store only in shared memory when using volatile.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vladimir Kuts, 2017-07-04
@fox_12

And here C#?
What components will be used? Is there a diagram of the device?
Is the servomotor not redundant for use as a damper? Maybe something simpler to apply - based on solenoids for example?
In the general case, the problem is solved. But you need to improve your device design skills, at least for a competent formulation of the problem.

A
Alexander Skusnov, 2017-07-06
@AlexSku

There are examples of watering plants on the Amperka.

E
evgeniy_lm, 2017-07-04
@evgeniy_lm

It is not clear what C# has to do with it. The
weak point is the bending hose, it will not bend for a particularly long time.
It would be more reliable and correct to put a normally closed valve, for example, such
. What exactly do you need help with, write to the mail

E
Eugene, 2017-07-04
@GoldGoblin

What about C#?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question