You iterate over the
items
array using indices from
t
array.
If they both have the same number of items, that works, but it's only by chance.
Better construct
t
using length of
items
.
Correct code would be:
string[] items = new string[] {"hi","hello","hey"};
Thread[] t = new Thread[items.length];
for(int i = 0 ; i < t.Length; i++)
{
string s = items[i];
t[i] = new Thread(() => work(s));
t[i].IsBackground = true;
uplist<string> up = new uplist<string>(t[i]);
up.Add_item(items[i]);
}