Скачиваний:
16
Добавлен:
01.05.2014
Размер:
660 б
Скачать
#include <strstream.h>
#include <thread.h>

#include "glob_dat.h"
glob_dat globx (0);
		
void* mod_val (void* np ) 
{
    int old_val=0, new_val;
    istrstream((char*)np) >> new_val;

    if (!globx.getval(&old_val)) {		// get current value
	globx = old_val + new_val;		// add new value
        cout << (int)thr_self() << ": arg='" << (char*)np 
             << "'-> " << globx << endl; // show result
    }
    return 0;
}


int main( int argc, char*argv[]) 
{
   thread_t tid;
   while (--argc > 0) 
      if (thr_create(0,0,mod_val,argv[argc],0,&tid))
         perror("thr_create");
   while (thr_join(0,0,0)) ;
   return 0;
}
Соседние файлы в папке glob_dat