/** * StatelessFactorizer * * A stateless servlet * * @author Brian Goetz and Tim Peierls */ @ThreadSafe publicclassStatelessFactorizerextendsGenericServletimplementsServlet{
/** * UnsafeCountingFactorizer * * Servlet that counts requests without the necessary synchronization * * @author Brian Goetz and Tim Peierls */ @NotThreadSafe publicclassUnsafeCountingFactorizerextendsGenericServletimplementsServlet{ privatelong count = 0;
/** * CountingFactorizer * * Servlet that counts requests using AtomicLong * * @author Brian Goetz and Tim Peierls */ @ThreadSafe publicclassCountingFactorizerextendsGenericServletimplementsServlet{ privatefinal AtomicLong count = new AtomicLong(0);
/** * CachedFactorizer * <p/> * Servlet that caches its last request and result * * @author Brian Goetz and Tim Peierls */ @ThreadSafe publicclassCachedFactorizerextendsGenericServletimplementsServlet{ @GuardedBy("this") private BigInteger lastNumber; @GuardedBy("this") private BigInteger[] lastFactors; @GuardedBy("this") privatelong hits; @GuardedBy("this") privatelong cacheHits;