Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #6862
| From | Robert Stark <panxiaozhong@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | A quota based lock |
| Followup-To | comp.lang.java.programmer |
| Date | 2011-08-08 00:13 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <83f81158-8aee-486d-a51b-c0f7dfdbb0da@h25g2000prf.googlegroups.com> (permalink) |
Followups directed to: comp.lang.java.programmer
I want to write a lock to control access to a resource, there are
different kind of jobs using this resource, say job A,B,C, at the
beginning, i use Lock api from jdk concurrent package, but i suffered
from serious job starvation, so i want to do something like this:
class T LockManager<T extends Enum>{
//the input is like this, A=>20, B=>70, C=>10, assign quota to
different jobs
public LockManager(Map<T,Integer> quota){
}
private void lock(T type){......}
private void unlock(T type){........}
public Lock getLock(T type){
return new QutaLock(type);
}
public class QutaLock implements Lock{
public QutaLock(T type){
.....
}
public void lock(){.....}
public void unlock(){.........}
......
}
}
My idea is input a map of percentages you want to assign for each job,
and provide a simple lock api.
Input A=>20, B=>70, C=>10 means A=>20%, B=>70%, C=>10%
If there's no A jobs pending on the lock, then its quota would be
divided evenly to other pending jobs that is B=>80%, C=>20%.(This rule
apply to other type of jobs as well).
Then i got stuck, the only way i can think about is to introduce an
extra dispatch thread and several queues, can someone give me some
hint?
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar
A quota based lock Robert Stark <panxiaozhong@gmail.com> - 2011-08-08 00:13 -0700
Re: A quota based lock Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-08-08 07:58 -0400
Re: A quota based lock Knute Johnson <september@knutejohnson.com> - 2011-08-08 09:48 -0700
Re: A quota based lock markspace <-@.> - 2011-08-08 10:00 -0700
Re: A quota based lock Knute Johnson <september@knutejohnson.com> - 2011-08-08 11:39 -0700
Re: A quota based lock markspace <-@.> - 2011-08-08 11:57 -0700
Re: A quota based lock Robert Klemme <shortcutter@googlemail.com> - 2011-08-08 21:46 +0200
Re: A quota based lock Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-08-08 20:41 -0400
Re: A quota based lock Robert Klemme <shortcutter@googlemail.com> - 2011-08-10 09:36 +0200
Re: A quota based lock Robert Stark <panxiaozhong@gmail.com> - 2011-08-10 04:40 -0700
Re: A quota based lock Robert Klemme <shortcutter@googlemail.com> - 2011-08-10 18:55 +0200
Re: A quota based lock Martin Gregorie <martin@address-in-sig.invalid> - 2011-08-10 19:26 +0000
Re: A quota based lock Patricia Shanahan <pats@acm.org> - 2011-08-10 12:37 -0700
Re: A quota based lock Robert Stark <panxiaozhong@gmail.com> - 2011-08-10 18:30 -0700
Re: A quota based lock markspace <-@.> - 2011-08-10 19:17 -0700
Re: A quota based lock Robert Klemme <shortcutter@googlemail.com> - 2011-08-11 12:32 +0200
Re: A quota based lock Tom Anderson <twic@urchin.earth.li> - 2011-08-09 21:00 +0100
Re: A quota based lock markspace <-@.> - 2011-08-08 07:58 -0700
Re: A quota based lock Tom Anderson <twic@urchin.earth.li> - 2011-08-09 21:45 +0100
csiph-web