/*
* 作者: cjdao@163.com
* 日期:2013-05-29
* 描述:
* 有四个线程1、2、3、4。线程1的功能就是输出A,线程2的功能就是输出B,以此类推.........
* 现在有四个文件file1, file2,file3, file4。初始都为空。现要让四个文件呈如下格式:
* file1:A B C D A B....
* file2:B C D A B C....
* file3:C D A B C D....
* file4:D A B C D A....
*/
#include <stdio.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
void *writer_routine(void *arg)
{
int index = (int)arg;
int file_index[4] ;
int can_write_file_cnt = 0;
int i = 0;
int next_index=0;
printf("thread %d is running, and will write '%c' to files\n", index, writer_char[index]);