Hello

An example I think for my students. A concurrent search for an element in two lists

declare
proc {Esta E L ?A Id}
   case L
   of nil then skip
   []X|Xs then if X==E then A=Id#true else {Esta E Xs ?A Id} end
   end
end

proc {Esta2 E L1 L2 ?A}
   thread {Esta E L1 ?A 1} end
   thread {Esta E L2 ?A 2} end
end
declare
Ls1= [1 3 5 7 9 11 13 15]
Ls2= [2 4 6 8 10 12 14 16 18]
R={Esta2 13 Ls1 Ls2} {Browse R}

It seems works. It's a good example? The question is: When one of the threads binds ?A, the others threads continue making the search. How can one stop the others threads to continue working?


Thanks (apologize for my english)

Julio H Vargas

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



_________________________________________
Universidad Tecnológica de Pereira
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to