OSF DCE Application Development Guide--Core Components

DCE Threads Example
/*
* Take the list of prime numbers found by the worker threads and
* sort them from lowest value to highest. The worker threads work
* concurrently; there is no guarantee that the prime numbers
* will be found in order. Therefore, a sort is performed.
*/
not_done = 1;
for (index1 = 1; ((index1 < request) && (not_done)); index1++) {
for (index2 = 0; index2 < index1; index2++) {
if (primes[index1] < primes[index2]) {
temp = primes[index2];
primes[index2] = primes[index1];
primes[index1] = temp;
not_done = 0;
}
}
}
/*
* Print out the list of prime numbers that the worker threads
* found.
*/
printf ("The list of %d primes follows:\n", request);
printf("%d",primes[0]);
for (list = 1; list < request; list++) {
printf (",%d", primes[list]);
}
printf ("\n");
}
124245 Tandem Computers Incorporated 107