#182062 - 2007-10-2909:36 PMRe: multi threading
[Re: vroedie]
Glenn BarnasGlenn Barnas KiX Supporter
Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
OK - here's a sample of "parent.kix" and "child.kix" that illustrates one way to do this - first, the PARENT script:
And the CHILD script:
The CHILD waits 0-4 seconds, then creates a .TMP file, waits an additional 0-4 seconds (to simulate work communicating to a remote system) and then renames the TMP file to INI before exiting.
PARENT quickly spawns off 10 children, then waits for INI files to appear. Each INI that appears reduces the worker count, allowing more children to be run, until all 15 have completed. The status line shows the count grow from 1-15, and the workers increase to 10, then decrease/increase until all 15 tasks have been initiated, and finally workers decreases to zero.
Again, it's a simple, silly example that illustrates the concept, but should be able to form the building block of what you need. You should probably incorporate a max time limit that you wait for workers to complete, or use some type of process interrogation so you don't wait for children that die before completing their tasks. Unlikely, but possible.
Hope this gets you going in the right direction! I tested this, and it should work to illustrate the concept just fine - using Kix 4.60 here..
Glenn
_________________________ Actually I am a Rocket Scientist!