Skip to content

Instantly share code, notes, and snippets.

@jkutner
Created January 4, 2011 16:26
Show Gist options
  • Save jkutner/764994 to your computer and use it in GitHub Desktop.
Save jkutner/764994 to your computer and use it in GitHub Desktop.
ServerProcess = spawn(web, start_server, [Port, MaxConnections]),
ServerProcess ! {pause, 10},
receive
a_message -> do_something;
{data, DataContent} -> handle(DataContent);
{hello, Text} -> io:format("Got hello message: ~s", [Text]);
{goodbye, Text} -> io:format("Got goodbye message: ~s", [Text])
end.
atomic (putR r 3);
(def current-song (ref "Canon in D"))
(deref current-song)
(ref-set current-song "Toccata in Fugue")
(dosync (ref-set current-song "Toccata in Fugue"))
type Resource = TVar Int
putR :: Resource -> Int -> STM ()
putR r i = do { v <- readTVar r
; writeTVar r (v+i) }
class ThreadSafeCounter {
private int c = 0;
public synchronized void increment() {
c++;
}
public synchronized void decrement() {
c--;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment