-----------더 볼거리--------------
1. balancer의 구현
- synchronization
public class Balancer {
Boolean toggle =TRUE;
public synchronized int traverse(t) {
if(toggle)
toggle = FALSE; return 0;
toggle = TRUE; return 1;
}
}
- CAS
while(true) {
boolean prior = toggle.get();
if(toggle.compareAndSet(prior, !prior)) {
return (prior? 0 : 1);
}
}
'분산시스템 (멀티코어 contention) - 수업' 카테고리의 다른 글
barriers (0) | 2017.06.21 |
---|---|
futures, scheduling, and work distribution (0) | 2017.06.21 |
priority queue (for concurrent) (0) | 2017.05.23 |
concurrent skip-list (0) | 2017.05.23 |
Concurrent Hashing (0) | 2017.05.23 |