将arraylist的值分配给Thread Array

将arraylist的值分配给Thread Array

问题描述:

我有一个包含10个值的arraylist.

我还创建了一个线程数组.
我想将线程arraylist值平均分配给数组中的每个线程,线程数为5.
IE.每个线程将从数组列表中获取2个值.

如何将arraylist中的这两个值分配给每个线程?
另外,我还需要并行运行这些线程.

I have an arraylist which contains 10 values.

I have also created a thread array.
I want to assign the thread arraylist values equally to each thread in the array, having a thread count as 5.
ie. Each thread will get 2 values from array list.

How do I assign those two values from arraylist to each thread?
Also I need to run those threads in parallel.

您可以将arraylist设为静态的全局公共项,并让每个线程访问它自己的索引在那个数组中.

编辑================

再一次,我不明白为什么将它评为1.这是一次诚实的尝试,目的是使您指出正确的方向.当我没有时间/渴望编写和测试它时,我将不提供代码.
You could make the arraylist a static globally public item, and just let each thread access it''s own index in that array.

EDIT ================

Once again, I don''t understand why this was voted a 1. It was an honest attempt at getting you pointed in the right direction. I''m not going to provide code when I don''t have time/desire to write and test it.