#include #include #include #include void *write_thread(void *arg) { int n = (int)arg; const int rows = 12; const int cols = 79; char buf[64]; for (int i=0; i<1; i++) { for (int r=1; r<=rows; r++) { for (int c=1; c<=cols; c++) { sprintf(buf, "\033[%d;%dH\033[%dm%c", r + n*rows, c, 31+n, 'A'+n); write(1, buf, strlen(buf)); } } } } int main() { pthread_t th1, th2; printf("\033[H\033[J"); fflush(stdout); if (pthread_create(&th1, NULL, write_thread, (void*)0)) { perror ("1: pthred_create"); return -1; } if (pthread_create(&th2, NULL, write_thread, (void*)1)) { perror ("2: pthred_create"); return -1; } pthread_join(th1, NULL); pthread_join(th2, NULL); usleep(3000000); printf("\033[H\033[J\033[m"); fflush(stdout); return 0; }