Exemplo n.º 1
0
u4 mythreadproc(AThread& thread)
{
  CommonData *pData = static_cast<CommonData *>(thread.getParameter());
  AASSERT(NULL, pData);

  u4 id = thread.getId();
  thread.setRunning(true);

  {
    {
      ALock lock(pData->m_cs);
      pData->m_count++;
    }

    {
      ALock lock(g_ConsoleOutput);
      std::cout << "[" << AString::fromU4(thread.getId()) << "," << pData->m_count << "]" << std::flush;
    }

    AThread::sleep(300);
  }

  thread.setRunning(false);

  return 0;
}
Exemplo n.º 2
0
u4 procMy(AThread& threadThis)
{
  cerr << threadThis.getId() << endl;

  ATimer timer;
  timer.start();
  for (u4 iX = 0x0; iX < 0x2000; ++iX)
  {
//    std::string str;
//    str.reserve(ARandomNumberGenerator::intRange(16384));
    AString str(ARandomNumberGenerator::intRange(16384), 128);
  }
  timer.stop();
  cerr << "Elapsed time " << timer.getInterval() << " ms" << endl;
  
  threadThis.setFlag(AThread::Done);
  return 0x0;
}