2011-04-09 19:55:52 +04:00
|
|
|
#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++;
|
|
|
|
|
2011-04-28 13:18:02 +04:00
|
|
|
//~ struct timespec ts;
|
2011-04-09 19:55:52 +04:00
|
|
|
//~ 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;
|
|
|
|
}
|
|
|
|
|