mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-28 06:12:37 -06:00
reorganizing repo
git-svn-id: svn://ultimatepp.org/upp/trunk@9206 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
7d17505cfe
commit
e3e8d627f5
3840 changed files with 0 additions and 1161578 deletions
|
|
@ -1,58 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <process.h>
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
#include <Core/Core.h>
|
||||
using namespace Upp;
|
||||
|
||||
int t0=GetTickCount();
|
||||
void t() { printf("%.2f\t",(GetTickCount()-t0)*1e-3); }
|
||||
std::vector<int> *v;
|
||||
Mutex mutex;
|
||||
|
||||
unsigned __stdcall th1(void*ctx) {
|
||||
int i=(int)ctx;
|
||||
t();printf("thread%d start\n",i);
|
||||
Sleep(100);
|
||||
{ Mutex::Lock lock(mutex);
|
||||
t();printf("clear & add item\n");
|
||||
v->clear();
|
||||
v->push_back(10+i);
|
||||
}
|
||||
Sleep(100);
|
||||
t();printf("thread%d done\n",i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void th0(int k) {
|
||||
v = new std::vector<int>();
|
||||
t();printf("born\n");
|
||||
for(int i=1;i<k;++i) {
|
||||
Sleep(100);
|
||||
int h=(int)_beginthreadex(0,0,th1,(void*)i,CREATE_SUSPENDED,0);
|
||||
t(); printf("create thread %d\n",h);
|
||||
Sleep(100);
|
||||
{ Mutex::Lock lock(mutex);
|
||||
v->clear();
|
||||
}
|
||||
t();printf("resume thread\n");
|
||||
ResumeThread((HANDLE)h);
|
||||
Sleep(300);
|
||||
{ Mutex::Lock lock(mutex);
|
||||
int n=v->size();
|
||||
t(); printf("n=%d ""x[n-1]=%d\n",n,n?(*v)[n-1]:-1);
|
||||
}
|
||||
}
|
||||
Sleep(100);
|
||||
{ Mutex::Lock lock(mutex);
|
||||
t();printf("clear\n");
|
||||
v->clear();
|
||||
}
|
||||
t();printf("kill\n");
|
||||
delete v;
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN{
|
||||
th0(4);
|
||||
printf("ready!\n");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue