44 lines
642 B
C
44 lines
642 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
#include <pthread.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
|
|
int a[ 5 ];
|
|
|
|
void * Thread( void* pParams )
|
|
{ int i, num = 0;
|
|
|
|
while ( 1 )
|
|
{
|
|
for ( i = 0; i < 5; i++ ) a[ i ] = num;
|
|
num++;
|
|
|
|
//~ struct timespec ts;
|
|
//~ ts.tv_sec = 0;
|
|
//~ ts.tv_nsec = 10;
|
|
//~ nanosleep(&ts,NULL);
|
|
|
|
}
|
|
}
|
|
|
|
int main( void )
|
|
{
|
|
pthread_t tr;
|
|
if(pthread_create(&tr,NULL,Thread,NULL) != 0)
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
// _beginthread( Thread, 0, NULL );
|
|
|
|
while( 1 )
|
|
printf("%d %d %d %d %d\n",
|
|
a[ 0 ], a[ 1 ], a[ 2 ],
|
|
a[ 3 ], a[ 4 ] );
|
|
|
|
return 0;
|
|
}
|
|
|