由买买提看人间百态

topics

全部话题 - 话题: maptest
(共0页)
r****m
发帖数: 70
1
来自主题: JobHunting版 - 贡献T家新鲜面经,求个bless
package test;
public class MapTest implements Runnable{

int[] a;
int index = 0;

MapTest(int[] a) {
this.a = a;
}

int fun(int i) {
return i+1;
}

@Override
public void run() {
int i;
while((i = getIndex()) < a.length) {
System.out.println(Thread.currentThread().getName() + " " + i);
a[i] = fun(a[i]);
}
}

synchronized int getIndex() {
return (index++);
}
static... 阅读全帖
(共0页)