@@ -130,7 +130,7 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
130130/* fork failed */
131131pg_log (PG_FATAL ,"could not create worker process: %s\n" ,strerror (errno ));
132132#else
133- /*use first empty array element */
133+ /* empty array element are always at the end */
134134new_arg = exec_thread_args [parallel_jobs - 1 ];
135135
136136/* Can only pass one pointer into the function, so use a struct */
@@ -244,7 +244,7 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
244244/* fork failed */
245245pg_log (PG_FATAL ,"could not create worker process: %s\n" ,strerror (errno ));
246246#else
247- /*use first empty array element */
247+ /* empty array element are always at the end */
248248new_arg = transfer_thread_args [parallel_jobs - 1 ];
249249
250250/* Can only pass one pointer into the function, so use a struct */
@@ -339,10 +339,10 @@ reap_child(bool wait_for_child)
339339thread_handles [thread_num ]= thread_handles [parallel_jobs - 1 ];
340340
341341/*
342- *We must swap the arg structpointers because thethread we just
343- *moved is active, andwe must make sure it is not reused by the next
344- *created thread.Instead, thenew threadwill usethe arg struct of
345- * thethread that just died .
342+ *Move last active thead arg structinto thenow-dead slot,
343+ * andthe now-dead slot to the end for reuse by the next thread.
344+ *Though the threadstruct is in useby another thread, we can
345+ *safely swap thestruct pointers within the array .
346346 */
347347tmp_args = cur_thread_args [thread_num ];
348348cur_thread_args [thread_num ]= cur_thread_args [parallel_jobs - 1 ];