Question: why mutex can not solve hangs problem

 in maple 12, it can not read table T in another worksheet.

i just want to read table T whenever i want during the running of big loop in procedure manman

 

restart;
with(Groebner):
AllMatrices := proc (A::set, k::posint, n::posint)
local B, C, E:
B := [[]]:
C := proc ()
B := [seq(seq([A[i], op(B[j])], i = 1 .. nops(A)), j = 1 .. nops(B))]:
end proc:
E := (C@@(k*n))(B):
seq(Matrix(k, n, E[m]), m = 1 .. nops(A)^(k*n));
end proc:
mm := AllMatrices({0, 1}, 3, 3);
GetRing := proc(sol)
ringequation := 0;
mono1 := 0;
for j from 1 to 3 do
mono1 := 1;
for i from 1 to nops(sol[1][j]) do
mono1 := mono1*op(i, sol[1][j]);
od:
ringequation := ringequation + mono1;
od:
return ringequation;
end proc;
with(LinearAlgebra):
polylistresult := [];
for i from 1 to nops([mm]) do
sol := MatrixMatrixMultiply(Matrix([[a,b,c]]), op(i,[mm]));
sol := GetRing(sol);
polylistresult := [op(polylistresult), sol];
od:
with(Groebner):
with(Threads):
T := Table();
m := Threads[Mutex][Create]();
manman := proc(T2, m2);
indexlistresult := [];
for i from 2 to nops(polylistresult) do
for j from 2 to nops(polylistresult) do
if i < j then
for k from 2 to nops(polylistresult) do

if j < k then
print("find");
F := [polylistresult[i], polylistresult[j], polylistresult[k]];
h := HilbertSeries(F, {x, y, z}, s);
if h <> 0 then
#if not assigned(T[h]) then
print(h);
Threads[Mutex][Lock]( m2 );
T2[h] := [op(T2[h]), F];
Threads[Mutex][Unlock]( m2 );
end if:
end if:
od:
end if:
od:
od:
end proc:
manman(T, m);
Threads[Mutex][Destroy](m);

another sheet:
Threads[Mutex][Lock]( m );
for i in indices(T) do
print(i);
od:
Threads[Mutex][Unlock]( m );

Please Wait...