Advertisement
Guest User

Untitled

a guest
Jul 28th, 2014
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. Перечислите все проблемы, которые вы видите в данном коде
  2.  
  3.   public abstract class Digest {
  4.       private Map<byte[], byte[]> cache = new HashMap<byte[], byte[]>();
  5.  
  6.       public byte[] digest(byte[] input) {
  7.           byte[] result = cache.get(input);
  8.           if (result == null) {
  9.               synchronized (cache) {
  10.                   result = cache.get(input);
  11.                   if (result == null) {
  12.                       result = doDigest(input);
  13.                       cache.put(input, result);
  14.                   }
  15.               }
  16.           }
  17.           return result;
  18.       }
  19.  
  20.       protected abstract byte[] doDigest(byte[] input);
  21.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement