












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













public interface Executor { void execute( Runnable command ); } public interface ExecutorService extends Executor { void shutdown() ; List
class WebServer { public static void main( String [] args) { ServerSocket socket = new ServerSocket ( 80 ); while ( true ) { final Socket connection = socket.accept(); Runnable r = new Runnable () { public void run () {handleRequest(connection);} }; new Thread (r).start(); } } }
public class Cache<K, V> { Map<K, Future
interface Lock { void lock(); void lockInterruptibly() throws IE; boolean tryLock(); boolean tryLock( long time ,TimeUnit unit ) throws IE; void unlock(); Condition newCondition() throws UnsupportedOperationException; }
interface ReadWriteLock { Lock readLock(); Lock writeLock(); }
class RWDictionaryRWL { private final Map < String , Data > m = new TreeMap < String , Data >(); private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock (); private final Lock r = rwl.readLock (); private final Lock w = rwl.writeLock (); public Data get( String key) { r.lock(); try { return m.get(key); } finally { r.unlock(); } } public Data put( String key, Data value) w.lock(); try { return m.put(key, value); } finally { w.unlock(); } } }
interface Condition { void await() throws IE ; boolean await( long time, TimeUnit unit ) throws IE ; long awaitNanos( long nanosTimeout) throws IE ; void awaitUninterruptibly() boolean awaitUntil( Date deadline) throws IE ; void signal(); void signalAll(); }
public Object take() throws IE { lock.lock(); try { while (count == 0) notEmpty.await(); Object x = items[takeptr]; if (++takeptr == items.length) takeptr = 0; --count; notFull.signal(); return x; } finally { lock.unlock(); } } }