コード例 #1
0
ファイル: main.cpp プロジェクト: loqutus/huyorg
int main(int argc, char** argv) {
  std::thread thread1(run_master);
  std::thread thread2(run_watcher);
  thread1.join();
  thread2.join();
  return 0;
}
コード例 #2
0
ファイル: B-2-program.c プロジェクト: thorstent/ConRepair
void main() {
  x = 0;
  y = 0;
  thread1();
  thread2();
  thread3();
}
コード例 #3
0
ファイル: osgunittests.cpp プロジェクト: joevandyk/osg
void testThreadInitAndExit()
{
    std::cout<<"******   Running thread start and delete test   ****** "<<std::endl;

    {
        MyThread thread;
        thread.startThread();
    }
    
    // add a sleep to allow the thread start to fall over it its going to.
    OpenThreads::Thread::microSleep(500000);
    
    std::cout<<"pass    thread start and delete test"<<std::endl<<std::endl;


    std::cout<<"******   Running notify thread test   ****** "<<std::endl;

    {
        NotifyThread thread1(osg::INFO,"thread one:");
        NotifyThread thread2(osg::INFO,"thread two:");
        NotifyThread thread3(osg::INFO,"thread three:");
        NotifyThread thread4(osg::INFO,"thread four:");
        thread1.startThread();
        thread2.startThread();
        thread3.startThread();
        thread4.startThread();

        // add a sleep to allow the thread start to fall over it its going to.
        OpenThreads::Thread::microSleep(5000000);
    }

    std::cout<<"pass    noitfy thread test."<<std::endl<<std::endl;
}
コード例 #4
0
ファイル: log.cpp プロジェクト: TomyLobo/TbdLib
int main(int ac, char* av[])
{
	LOG_MSG << "LogTestApp. -- written by Wilston Oreo.";

#ifdef TEST_THREADS

	srand ( time(NULL) );

	LOG_MSG_(1) << "Startup";  
	boost::thread thread1(threadLog);
	boost::thread thread2(threadLog);
	boost::thread thread3(threadLog);
	boost::thread thread4(threadLog);
	LOG_MSG_(1) << "Waiting for threads...";

	thread1.join();
	thread2.join();
	thread3.join();
	thread4.join();

#endif

	LOG_MSG_(1) << "Done";

	LOG->level(2);

	LOG_MSG_(1) << fmt("Log level: %") % LOG->level();
	LOG_WRN << fmt("Warning %") % 3;
	LOG_MSG_(3);
	LOG_MSG_(4);
	LOG_ERR << "ERROR";

	return 0;
}
コード例 #5
0
ファイル: test_7755.cpp プロジェクト: AlexMioMio/boost
int main()
{
  std::cout << "Starting" << std::endl;

  // 1 - lock the mutex
  boost::shared_lock<boost::shared_mutex> lock (mutex);

  // 2 - start thread#2
  boost::thread thread2(&thread2_func);

  // 3 - sleep
  boost::this_thread::sleep(boost::posix_time::milliseconds(10));

  std::cout << "Thread#2 is waiting" << std::endl;

  // - start thread3
  boost::thread thread3(&thread3_func);
  //boost::thread thread3(&thread3_func_workaround);

  std::cout << "Thread#3 is started and blocked. It never will waked" << std::endl;

  thread3.join(); // will never return

  lock.unlock(); // release shared ownership. thread#2 will take unique ownership

  thread2.join();

  std::cout << "Finished" << std::endl;
  return 0;
}
コード例 #6
0
ファイル: B-3-program.c プロジェクト: thorstent/ConRepair
void main() {
  starting = 1;
  IntrMask = 0;
  patched = 0;
  thread1();
  thread2();
}
コード例 #7
0
main() {
    IntrMask = 0;
    intr_mask = 0;
    handled = 0;
  thread1();
  thread2();
}
コード例 #8
0
ファイル: cancel_thread.cpp プロジェクト: untgames/funner
int main ()
{
  printf ("Results of cancel_thread_test:\n");

  try
  {
    LogFilter filter ("system.threads.*", &print_log);

    Thread thread1 (&thread1_run), thread2 (&thread2_run);

    thread [0] = &thread1;
    thread [1] = &thread2;
    
    int result1 = thread [1]->Join (), result0 = thread [0]->Join ();

    printf ("join thread2: %d\n", result1);
    printf ("join thread1: %d\n", result0);
    fflush (stdout);
  }
  catch (std::exception& exception)
  {
    printf ("exception: %s\n", exception.what ());
  }

  return 0;
}
コード例 #9
0
ファイル: cache.c プロジェクト: BeFra/ConcurrentSystems
static void t2(void* a, void* b)
{
    (void) a;
    (void) b;
	thread2();
	lwt_sig_signal(sig);
}
コード例 #10
0
int main() {
	std::mutex m;
	std::condition_variable cond_var;
    std::thread thread1([&m, &cond_var](){
        for(;;) {
        	std::this_thread::sleep_for(std::chrono::seconds(1));
        	std::unique_lock<std::mutex> lock(m);
        	std::cout << "first" << std::endl;
        	cond_var.notify_one();
        }
    });

    std::thread thread2([&m, &cond_var](){
        for(;;) {
        	std::unique_lock<std::mutex> lock(m);
        	cond_var.wait(lock);
        	std::cout << "second" << std::endl;
        }
    });

    thread1.join();
    thread2.join();

    return 0;
}
コード例 #11
0
//-*****************************************************************************
int main( int argc, char* argv[] )
{
    boost::thread thread1( &test );
    boost::thread thread2( &test );
    thread1.join();
    thread2.join();
    return 0;
}
コード例 #12
0
int main() {
  __CPROVER_ASYNC_1: thread1();
  __CPROVER_ASYNC_1: thread2();
  __CPROVER_ASYNC_1: thread3();
  __CPROVER_assume(y==3);
  assert(x!=1);
  return 0;
}
コード例 #13
0
ファイル: preset_tests.cpp プロジェクト: Ribtoks/xpiks
void PresetTests::parallelAccessTest() {
    const int initIterations = 100;
    const int itemsToGenerate = 5;
    DECLARE_MODELS_AND_GENERATE(itemsToGenerate);

    QString presetName = "preset";
    QStringList keywords;
    keywords << "keyword1" << "another keyword" << "test";

    Helpers::Barrier barrier1(2), barrier2(2);
    bool isAdded1, isAdded2;
    volatile bool removed1;
    volatile bool removed2;
    KeywordsPresets::ID_t id1 = 0;
    KeywordsPresets::ID_t id2 = 0;

    std::thread thread1([&]() {
        int n = initIterations;
        while (n--) {
            isAdded1 = false; id1 = 0;
            presetKeywordsModel.addOrUpdatePreset(presetName, keywords, id1, isAdded1);

            /*-------------*/barrier1.wait();

            Q_ASSERT(isAdded1 != isAdded2);
            Q_ASSERT(id1 == id2);

            removed1 = presetKeywordsModel.removePresetByID(id1);

            /*-------------*/barrier2.wait();

            Q_ASSERT(removed1 != removed2);
        }
    });

    std::thread thread2([&]() {

        int n = initIterations;
        while (n--) {
            isAdded2 = false; id2 = 1;
            presetKeywordsModel.addOrUpdatePreset(presetName, keywords, id2, isAdded2);

            /*-------------*/barrier1.wait();

            Q_ASSERT(isAdded1 != isAdded2);
            Q_ASSERT(id1 == id2);

            removed2 = presetKeywordsModel.removePresetByID(id2);

            /*-------------*/barrier2.wait();

            Q_ASSERT(removed1 != removed2);
        }
    });

    thread1.join();
    thread2.join();
}
コード例 #14
0
ファイル: app with space.cpp プロジェクト: halsten/beaverdbg
void testThreads()
{
    Thread thread1(1);
    Thread thread2(2);
    thread1.start();
    thread2.start();
    thread1.wait();
    thread2.wait();
}
コード例 #15
0
ファイル: B-2-program.c プロジェクト: thorstent/ConRepair
void main() {
  registered = 0;
  initialised1 = 0;
  initialised2 = 0;
  initialised3 = 0;
  thread1();
  thread2();
  thread3();
}
コード例 #16
0
ファイル: main.c プロジェクト: diffblue/2ls
void main()
{
  while(1)
  {
    thread1();
    thread2();
    if(exit==0) break;
  }
}
コード例 #17
0
int main()
{
   std::thread thread1(function_modifying_global_struct, 1);
   std::thread thread2(function_modifying_global_struct, 2);

   thread1.join();
   thread2.join();

   return 0;
}
コード例 #18
0
ファイル: main.cpp プロジェクト: akozlins/util
void main()
{
  for(int i = 0; i < 10; i++)
  {
    boost::thread thread1(boost::bind(&func1));
    boost::thread thread2(boost::bind(&func2));
    thread2.join();
    thread1.join();
  }
}
コード例 #19
0
ファイル: B-2-program.c プロジェクト: thorstent/ConRepair
void main() {
  napi_poll = 0;
  shutdown = 0;
  stuff1_done = 0;
  updated = 0;
  napi_disabled = 0;
  thread1();
  thread2();
  thread3();
}
コード例 #20
0
ファイル: main.cpp プロジェクト: CCJY/coliru
int main ()
{
    std::thread thread1(task1);
    std::thread thread2(task2);

    thread1.join();
    thread2.join();

    return EXIT_SUCCESS;
}
コード例 #21
0
ファイル: lazy01.c プロジェクト: quytc/TARA
void main()
{
  data = 0;
  mutex = 0;
  
  thread1();
  thread2();
  thread3();
  
}
コード例 #22
0
ファイル: mutex.cpp プロジェクト: skyformat99/thread-
int main()
{
	boost::thread thread1(boost::bind(func, "tom", 160));
	boost::thread thread2(boost::bind(func, "glen", 500));

	sleep(3);
	thread1.join();
	thread2.join();
	return 0;
}
コード例 #23
0
ファイル: threadTest.cpp プロジェクト: sauver/sauver_sys
int main(int argc, char **argv) 
{
  Aria::init(Aria::SIGHANDLE_THREAD, false);

  ArMutex mutex;
  mutex.setLogName("mutex");

  ArMutex::setLockWarningTime(1);
  ArMutex::setUnlockWarningTime(5);
  TestThread thread1(1, mutex), thread2(2, mutex), thread3(3, mutex),
    thread4(4, mutex);

  thread1.setThreadName("thread1");
  thread2.setThreadName("thread2");
  thread3.setThreadName("thread3");
  thread4.setThreadName("thread4");
  srand(time(0));


  thread1.create();
  thread2.create();
  thread3.create();

  printf("main thread name=\"%s\", OS handle=%lu, OS pointer=0x%x\n", ArThread::getThisThreadName(), ArThread::getThisOSThread(), (unsigned int) ArThread::getThisThread());
  printf("thread1 thread name=\"%s\", OS handle=%lu, OS pointer=0x%x\n", thread1.getThreadName(), thread1.getOSThread(), (unsigned int) thread1.getThread());
  printf("thread2 thread name=\"%s\", OS handle=%lu, OS pointer=0x%x\n", thread2.getThreadName(), thread2.getOSThread(), (unsigned int) thread2.getThread());
  printf("thread3 thread name=\"%s\", OS handle=%lu, OS pointer=0x%x\n", thread3.getThreadName(), thread3.getOSThread(), (unsigned int) thread3.getThread());
  printf("thread4 (not created yet) thread name=\"%s\", OS handle=%lu, OS pointer=0x%x\n", thread4.getThreadName(), thread4.getOSThread(), (unsigned int) thread4.getThread());
  if(ArThread::getThisOSThread() == thread1.getOSThread() ||
     ArThread::getThisOSThread() == thread2.getOSThread() ||
     ArThread::getThisOSThread() == thread3.getOSThread() ||
     ArThread::getThisOSThread() == thread4.getOSThread() ||
     thread1.getOSThread() == thread2.getOSThread() ||
     thread1.getOSThread() == thread3.getOSThread() ||
     thread1.getOSThread() == thread4.getOSThread() ||
     thread2.getOSThread() == thread1.getOSThread() ||
     thread2.getOSThread() == thread3.getOSThread() ||
     thread2.getOSThread() == thread4.getOSThread() ||
     thread3.getOSThread() == thread1.getOSThread() ||
     thread3.getOSThread() == thread2.getOSThread() ||
     thread3.getOSThread() == thread4.getOSThread() ||
     thread4.getOSThread() == thread1.getOSThread() ||
     thread4.getOSThread() == thread2.getOSThread() ||
     thread4.getOSThread() == thread3.getOSThread() )
  {
    puts("error, some thread IDs are the same!");
    return 5;
  }

  thread4.runInThisThread();

  Aria::shutdown();

  return(0);
}
コード例 #24
0
ファイル: main.cpp プロジェクト: CCJY/coliru
int main()
{
    A object ;
    
    std::thread thread( &A::foo /* function */ , &object /* this */, 1234 /* arg */ ) ;
    thread.join() ;
    
    // object is moved to the thread
    std::thread thread2( &A::foo, std::move(object), 5678 ) ;
    thread2.join() ;
}
コード例 #25
0
ファイル: B-5-program.c プロジェクト: thorstent/ConRepair
void main() {
  x = 0;
  y = 0;
  z = 0;
  a = 0;
  b = 0;
  thread1();
  thread2();
  thread3();
  thread4();
}
コード例 #26
0
ファイル: main.cpp プロジェクト: CCJY/coliru
int main()
{
	mystack<std::function<bool()>> stk; // une version sans pointeurs serait meilleure/plus simple
	int n = 10;
	std::thread thread1(fun1, std::ref(stk), std::ref(n));
	std::thread thread2(fun2, std::ref(stk));
	thread1.join();
	thread2.join();
	std::cout << "Fin." << std::endl;
	return 0;
}
コード例 #27
0
ファイル: concurrent.cpp プロジェクト: MayukhSobo/c-11
int main(){

    Worker w1 {5};
    std::thread thread1(w1);
    thread_guard tg1(thread1);

    Worker w2 {7};
    std::thread thread2(w2);
    thread_guard tg2(thread2);

    Worker w3 {9};
    std::thread thread3(w3);
    thread_guard tg3(thread3);
    return 0;
}
コード例 #28
0
ファイル: Test.cpp プロジェクト: Enzo-Liu/app
void testMutilQueue(int testSize )
{
    BlockingQueue<string> t_queue(testSize);
    char* c_str = new char[1024];
    memset(c_str, 0, 1024);
    string msg(c_str);
    QueueThread thread1(t_queue,true,testSize,&msg);
    QueueThread thread2(t_queue,false,testSize,NULL);

    thread1.start();
    thread2.start();

    sleep(100);
    delete[] c_str;
}
コード例 #29
0
bool ServiceLocator::test() {
    bool result = true;
    
    int n = 0;
    
    ServiceLocator* loc = ServiceLocator::getDefaultLocator();
    
    std::thread thread1(testThread, ++n, loc);
    std::thread thread2(testThread, ++n, loc);
    
    thread1.join();
    thread2.join();
    
    return result;
}
コード例 #30
0
int main()
{
    // Crear algunos hilos independientes cada uno de los cuales
    // ejecutará increment_counter()
    std::thread thread1(increment_counter);
    std::thread thread2(increment_counter);

    // Esperar a que los hilos terminen antes de que main() continúe.
    // Si no esperamos, corremos el riesgo de terminar el proceso y todos
    // sus hilos antes de que los hilos hayan terminado.
    thread1.join();
    thread2.join();
 
    std::cout << "Valor final del contador: " << counter << "\n";

    return 0;
}