xinjinlong | 2010-11-03 23:42:02    阅读：12913   发布文章
simple one
#include <stdio.h>
void* print_xs(void* unused){
while(1)
fputc('x',stderr);
return NULL;

}
int main()
{
the print_xs function*/
while(1){
fputc('o',stderr);
}
return 0;

}
#include <stdio.h>
struct char_print_parms
{
char character;
int count;
};
void* char_print(void* parameters)
{
struct char_print_parms* p =(struct char_print_parms*)parameters;
int i ;
for(i=0 ; i<p->count;i++)
fputc(p->character,stderr);
return NULL;

}
int main()
{

return 0;
}

#include <stdio.h>

/* Compute successive prime numbers (very inefficiently).  Return the
Nth prime number, where N is the value pointed to by *ARG.  */

void* compute_prime (void* arg)
{
int candidate = 2;
int n = *((int*) arg);

while (1) {
int factor;
int is_prime = 1;

/* Test primality by successive division.  */
for (factor = 2; factor < candidate; ++factor)
if (candidate % factor == 0) {
is_prime = 0;
break;
}
/* Is this the prime number we're looking for?  */
if (is_prime) {
if (--n == 0)
/* Return the desired prime number
* as the thread return value.  */
return (void*) candidate;
}
++candidate;
}

printf("The %dth prime number \n", candidate);
return NULL;
}

int main ()
{
int which_prime = 5000;
int prime;

/* Start the computing thread, up to the 5000th prime number.  */
/* Do some other work here...  */
/* Wait for the prime number thread to complete, and get the
* result.  */