# How can I change a variable from one process to another if the two processes are on different machines?

**URL:** <https://discourse.julialang.org/t/how-can-i-change-a-variable-from-one-process-to-another-if-the-two-processes-are-on-different-machines/67199>\
**Category:** New to Julia\
**Tags:** parallel, distributed\
**Created:** [August 28, 2021, 2:55am UTC](https://discourse.julialang.org/t/how-can-i-change-a-variable-from-one-process-to-another-if-the-two-processes-are-on-different-machines/67199 "2021-08-28T02:55:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frisus95](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@Frisus95](https://discourse.julialang.org/u/Frisus95)\
**Post date:** [August 28, 2021, 2:55am UTC](https://discourse.julialang.org/t/how-can-i-change-a-variable-from-one-process-to-another-if-the-two-processes-are-on-different-machines/67199/1 "2021-08-28T02:55:15Z")

</div>

Goodmorning everyone!

I have a pretty simple question.

If I am using N processes (on a cluster, potentially with processes defined on different nodes) and I want to make sure that each process is able to modify a variable (or an array) defined only in the master process, how can I do this?

In practice I would like to “check” all processes and make sure that a variable (defined only in the master process) is modified only if a certain condition is met in at least one of the processes.

Thanks everyone in advance!

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [August 28, 2021, 2:15pm UTC](https://discourse.julialang.org/t/how-can-i-change-a-variable-from-one-process-to-another-if-the-two-processes-are-on-different-machines/67199/2 "2021-08-28T14:15:05Z")

</div>

I’m not an expert on this, but I’ll respond because nobody else has taken it.

A worked out example of distributed computing can be found here:

> [@The ultimate guide to distributed computing](https://discourse.julialang.org/t/the-ultimate-guide-to-distributed-computing/41867):
>
> HOWTO: Distributed computing In this thread I would like to put together relevant information for people interested in distributing simple function calls on multiple cluster nodes. Although the task is simple, there are some rough (undocumented) corners in the language that inhibit even experienced users from accomplishing it currently. The idea here is to update this content every now and then to reflect the latest (and cleanest) way of performing distributed computing with remote workers in…

For your first question, it sounds like you are looking for a SharedArray.  
For the second, to prevent a race condition you would use a lock (pointer in the above thread). But I may misunderstand what you are asking for in your last paragraph.
