SetSharedVariable
This feature is not supported on the Wolfram Cloud.

SetSharedVariable[s1,s2,]
declares the symbols as shared variables whose values are synchronized among all parallel kernels.

DetailsDetails

  • The unique value of a shared variable is maintained by the master kernel and every access on a parallel subkernel is synchronized through the master kernel.
  • Shared variables without a value evaluate to Null.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

Make xs be a (global) shared variable:

In[1]:=
Click for copyable input

Each subkernel increments the (global) shared variable value:

In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

Without sharing, each subkernel has its own (local) copy of the variable:

In[4]:=
Click for copyable input
In[5]:=
Click for copyable input
Out[5]=
In[6]:=
Click for copyable input
Out[6]=
Introduced in 2008
(7.0)
Translate this page: