1、多进程编程
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
pid_t child_pid;
/* 创建一个子进程 */
child_pid = fork();
if(child_pid == 0)
{
printf("child pid\n");
exit(0);
}
else
{
printf("father pid\n");
sleep(60);
}
return 0;
}
2、多线程编程
#include <stdio.h>
#include <pthread.h>
struct char_print_params
{
char character;
int count;
};
void *char_print(void *parameters)
{
struct char_print_params *p = (struct char_print_params *)parameters;
int i;
for(i = 0; i < p->count; i++)
{
fputc(p->character,stderr);
}
return NULL;
}
int main()
{
pthread_t thread1_id;
pthread_t thread2_id;
struct char_print_params thread1_args;
struct char_print_par