模似CLE多线程处理2
package com.huawei.esb.cle;
public class SetCLEEntity extends Thread
{
// 每次取500
private int dafultIndex = 10;
// 每5秒种取一次
private int dafultTime = 5;
// 要设置值的对象
public void run()
{
boolean isRuning = true;
while (isRuning)
{
synchronized (TestCle.listAll)
{
if (!TestCle.listAll.isEmpty())
{
if (TestCle.listAll.size() > 10)
{
for (int i = 1; i <= dafultIndex; i++)
{
CleEntity entity = TestCle.listAll.get(i - 1);
Cache.tasks.add(entity);
TestCle.listAll.remove(i - 1);
}
}
else
{
for (int i = 1; i <= TestCle.listAll.size(); i++)
{
CleEntity entity = TestCle.listAll.get(i - 1);
Cache.tasks.add(entity);
TestCle.listAll.remove(i - 1);
}
}
}
}
}
}
}