Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. package com.intuit;
  2.  
  3. import java.util.Calendar;
  4. import java.util.concurrent.atomic.LongAdder;
  5.  
  6. class TPSCounter {
  7. LongAdder count;
  8. int threshold = 2;
  9.  
  10. Calendar expiry = null;
  11.  
  12. TPSCounter() {
  13. this.count = new LongAdder();
  14. this.expiry = Calendar.getInstance();
  15. this.expiry.add(Calendar.MINUTE, 1);
  16. }
  17.  
  18. boolean isExpired() {
  19. return Calendar.getInstance().after(expiry);
  20. }
  21.  
  22. boolean isWeak() {
  23. return (count.intValue() > threshold);
  24. }
  25.  
  26. void increment() {
  27. count.increment();
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement