I would do it a bit differently. Decide ahead of time how many threads and then divvy up the work like so:
/* worker.p
*
* i.e.:
* mbpro dbName -p worker.p -param "0,5"
* mbpro dbName -p worker.p -param "1,5"
* mbpro dbName -p worker.p -param "2,5"
* mbpro dbName -p worker.p -param "3,5"
* mbpro dbName -p worker.p -param "4,5"
*
* in this sample the threadNum starts at 0 -- so end it at numThreads - 1
*
*/
define variable threadNum as integer no-undo.
define variable numThreads as integer no-undo.
assign
threadNum = integer( entry( 1, session:parameter ))
numThreads = integer( entry( 2, session:parameter ))
.
for each item no-lock where (( item.item modulo numThreads ) = threadnum ):
/* whatever */
end.
return.
For starters I suggest that numThreads be roughly the number of cores available in the server.
Also, headless batch processes shouldn't be using prowin32.exe. They should use _progres.exe.
8.3 is unspeakably ancient, obsolete and unsupported. Is this system running on a single core Pentium with Windows 3.11? That's relevant because the 8.3 "workgroup edition" will not behave very well if this is a multi-core system. If it is "enterprise" it won't be so bad. But even so you'd be very well advised to upgrade to a current release (11.3 as of this writing) if performance is at all important to you.