次のJavaクラスに相当するCが必要です。これは、スレッド同期で使用されるアンダーソン・ロックと呼ばれるキュー・ロックです。私はCを使用するのが快適ではなく、使用方法がわからないスレッドクラスがいくつかあります。ありがとう。Solaris上のAndersonキューロック
私はOpenSolarisを使用しています。
public class ALock implements Lock { ThreadLocal mySlotIndex = new ThreadLocal(){ protected Integer initialValue() { return 0; } }; AtomicInteger tail; boolean[] flag; int size; public ALock(int capacity) { size = capacity; tail = new AtomicInteger(0); flag = new boolean[capacity]; flag[0] = true; } public void lock() { int slot = tail.getAndIncrement() % size; mySlotIndex.set(slot); while (! flag[slot]) {}; } public void unlock() { int slot = mySlotIndex.get(); flag[slot] = false; flag[(slot + 1) % size] = true; } }