NoFear

导航

多线程 分配

Posted on 2011-12-19 09:31  Fear_Hao  阅读(133)  评论(0编辑  收藏  举报
View Code
    int thread_num= mThreadnum-1;
int i;
int count=pwdvect.size();
int per = count / thread_num;
int yu = count % thread_num;
int x = 0, y = 0;
for (i = 0; i != thread_num; i++)
{
if (i == 0)
{
x = 0;
y = per - 1;
}
else
{
x = y + 1;
y = x + per - 1;
}
mBegin[i] = x;
mEnd[i] = y;
}

mBegin[i] = pwdvect.size() - yu;
mEnd[i] = pwdvect.size()-1;