Index: doc/papers/concurrency/examples/DatingServiceThread.cfa
===================================================================
--- doc/papers/concurrency/examples/DatingServiceThread.cfa	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
+++ doc/papers/concurrency/examples/DatingServiceThread.cfa	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
@@ -0,0 +1,110 @@
+#include <stdlib.hfa>									// random
+#include <fstream.hfa>
+#include <kernel.hfa>
+#include <thread.hfa>
+#include <unistd.h>										// getpid
+
+enum { CompCodes = 20 };								// number of compatibility codes
+
+thread DatingService {
+	condition Girls[CompCodes], Boys[CompCodes];
+	unsigned int girlPhoneNo, boyPhoneNo, ccode;
+}; // DatingService
+
+unsigned int girl( DatingService & mutex ds, unsigned int phoneno, unsigned int code ) with( ds ) {
+	girlPhoneNo = phoneno;  ccode = code;
+	wait( Girls[ccode] );								// wait for boy
+	girlPhoneNo = phoneno;
+	sout | "Girl:" | girlPhoneNo | "is dating Boy at" | boyPhoneNo | "with ccode" | ccode;
+	return boyPhoneNo;
+} // DatingService girl
+
+unsigned int boy( DatingService & mutex ds, unsigned int phoneno, unsigned int code ) with( ds ) {
+	boyPhoneNo = phoneno;  ccode = code;
+	wait( Boys[ccode] );								// wait for girl
+	boyPhoneNo = phoneno;
+	sout | " Boy:" | boyPhoneNo | "is dating Girl" | girlPhoneNo | "with ccode" | ccode;
+	return girlPhoneNo;
+} // DatingService boy
+
+void main( DatingService & ds ) with( ds ) {			// thread starts
+	for () {
+		waitfor( ^?{} : ds ) {
+			break;
+		} or waitfor( girl : ds ) {
+			if ( ! is_empty( Boys[ccode] ) ) {			// no compatible boy ?
+				signal_block( Boys[ccode] );			// restart boy to set phone number
+				signal_block( Girls[ccode] );			// restart girl to set phone number
+			} // if
+		} or waitfor( boy : ds ) {
+			if ( ! is_empty( Girls[ccode] ) ) {			// no compatible girl ?
+				signal_block( Girls[ccode] );			// restart girl to set phone number
+				signal_block( Boys[ccode] );			// restart boy to set phone number
+			} // if
+		}
+	}
+} // DatingService main
+
+unsigned int girlck[CompCodes];
+unsigned int boyck[CompCodes];
+
+thread Girl {
+	DatingService & TheExchange;
+	unsigned int id, ccode;
+}; // Girl
+
+void main( Girl & g ) with( g ) {
+	yield( random( 100 ) );								// do not start at the same time
+	unsigned int partner = girl( TheExchange, id, ccode );
+	girlck[id] = partner;
+} // Girl main
+
+void ?{}( Girl & g, DatingService * TheExchange, unsigned int id, unsigned int ccode ) {
+	&g.TheExchange = TheExchange;
+	g.id = id;
+	g.ccode = ccode;
+} // Girl ?{}
+
+thread Boy {
+	DatingService & TheExchange;
+	unsigned int id, ccode;
+}; // Boy
+
+void main( Boy & b ) with( b ) {
+	yield( random( 100 ) );								// don't all start at the same time
+	unsigned int partner = boy( TheExchange, id, ccode );
+	boyck[id] = partner;
+} // Boy main
+
+void ?{}( Boy & b, DatingService * TheExchange, unsigned int id, unsigned int ccode ) {
+	&b.TheExchange = TheExchange;
+	b.id = id;
+	b.ccode = ccode;
+} // Boy ?{}
+
+int main() {
+	DatingService TheExchange;
+	Girl * girls[CompCodes];
+	Boy  * boys[CompCodes];
+
+	srandom( /*getpid()*/ 103 );
+
+	for ( i; (unsigned int)CompCodes ) {
+		girls[i] = new( &TheExchange, i, i );			// TheExchange constructor needs unsigned int
+		boys[i]  = new( &TheExchange, i, CompCodes - ( i + 1 ) );
+	} // for
+
+	for ( i; CompCodes ) {
+		delete( boys[i] );
+		delete( girls[i] );
+	} // for
+
+	for ( i; CompCodes ) {
+		if ( girlck[ boyck[i] ] != boyck[ girlck[i] ] ) abort();
+	} // for
+} // main
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa DatingServiceThread.cfa" //
+// End: //
Index: doc/papers/concurrency/examples/Fib.js
===================================================================
--- doc/papers/concurrency/examples/Fib.js	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
+++ doc/papers/concurrency/examples/Fib.js	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
@@ -0,0 +1,18 @@
+function * fib() {
+	var fn1 = 1, fn = 0;
+	while ( true ) {
+		var ret = fn; fn = fn1; fn1 = fn + ret;
+		yield ret;
+	} // while
+}
+
+f1 = fib();
+f2 = fib();
+for ( var i = fib.length; i < 10; i += 1 ) {
+	console.log( f1.next().value, f2.next().value );
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "node Fib.js" //
+// End: //
Index: doc/papers/concurrency/examples/Format.js
===================================================================
--- doc/papers/concurrency/examples/Format.js	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
+++ doc/papers/concurrency/examples/Format.js	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
@@ -0,0 +1,33 @@
+function * Format() {
+	var g, b;
+	fini: while ( true ) {
+		for ( g = 0; g < 5; g += 1 ) {					// groups of 5 blocks
+			for ( b = 0; b < 4; b += 1 ) {				// blocks of 4 characters
+				while ( true ) {
+					ch = (yield)						// receive from send
+					if ( ch == '\0' ) break fini;
+					if ( '\n' != ch ) break
+				}
+				process.stdout.write( ch )				// receive from send
+			}
+			process.stdout.write( '  ' )				// block separator
+		}
+		process.stdout.write( '\n' )					// group separator
+	}
+	if ( g != 0 || b != 0 ) process.stdout.write( '\n' )
+}
+
+var input = "abcdefghijklmnop\nqrstuvwx\nyzxxxxxxxxxxxxx"
+
+fmt = Format()
+fmt.next()												// prime generator
+for ( var i = 0; i < input.length; i += 1 ) {
+	fmt.next( input[i] );								// send to yield
+}
+fmt.next( '\0' );										// EOF
+
+// Local Variables: //
+// comment-column: 56 //
+// tab-width: 4 //
+// compile-command: "node Format.js" //
+// End: //
Index: doc/papers/concurrency/examples/RWMonitorEXT.cfa
===================================================================
--- doc/papers/concurrency/examples/RWMonitorEXT.cfa	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
+++ doc/papers/concurrency/examples/RWMonitorEXT.cfa	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
@@ -0,0 +1,66 @@
+#include <fstream.hfa>
+#include <thread.hfa>
+
+volatile int SharedRW = 0;								// shared variable to test readers and writers
+
+monitor ReadersWriter {
+	int rcnt, wcnt;										// number of readers/writer using resource
+};
+
+void ?{}( ReadersWriter & rw ) with(rw) { rcnt = wcnt = 0; }
+void EndRead( ReadersWriter & mutex rw ) with(rw) { rcnt -= 1; }
+void EndWrite( ReadersWriter & mutex rw ) with(rw) { wcnt = 0; }
+void StartRead( ReadersWriter & mutex rw ) with(rw) {
+	if ( wcnt > 0 ) waitfor( EndWrite : rw );
+	rcnt += 1;
+}
+void StartWrite( ReadersWriter & mutex rw ) with(rw) {
+	if ( wcnt > 0 ) waitfor( EndWrite : rw );
+	else while ( rcnt > 0 ) waitfor( EndRead : rw );
+	wcnt = 1;
+}
+int readers( ReadersWriter & rw ) { return rw.rcnt; }
+
+void Read( ReadersWriter & rw ) {
+	StartRead( rw );
+	sout | "Reader:" | active_thread() | ", shared:" | SharedRW | " with:" | readers( rw ) | " readers";
+	yield( 3 );
+	EndRead( rw );
+}
+void Write( ReadersWriter & rw ) {
+	StartWrite( rw );
+
+	SharedRW += 1;
+	sout | "Writer:" | active_thread() | ",  wrote:" | SharedRW;
+	yield( 1 );
+	EndWrite( rw );
+}
+
+thread Worker {
+	ReadersWriter &rw;
+};
+void ?{}( Worker & w, ReadersWriter * rw ) { &w.rw = rw; }
+void main( Worker & w ) with(w) {
+	for ( 10 ) {
+		if ( rand() % 100 < 70 ) {					// decide to be a reader or writer
+			Read( rw );
+		} else {
+			Write( rw );
+		} // if
+	} // for
+}
+
+int main() {
+	enum { MaxTask = 5 };
+	ReadersWriter rw;
+	Worker *workers[MaxTask];
+
+	for ( i; MaxTask ) workers[i] = new( &rw );
+	for ( i; MaxTask ) delete( workers[i] );
+	sout | "successful completion";
+} // main
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa -O2 RWMonitorEXT.cfa" //
+// End: //
Index: doc/papers/concurrency/examples/RWMonitorINT.cfa
===================================================================
--- doc/papers/concurrency/examples/RWMonitorINT.cfa	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
+++ doc/papers/concurrency/examples/RWMonitorINT.cfa	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
@@ -0,0 +1,74 @@
+#include <fstream.hfa>
+#include <thread.hfa>
+
+volatile int SharedRW = 0;								// shared variable to test readers and writers
+
+enum RW { READER, WRITER };
+monitor ReadersWriter {
+	int rcnt, wcnt;										// number of readers/writer using resource
+	condition RWers;
+};
+
+void ?{}( ReadersWriter & rw ) with(rw) { rcnt = wcnt = 0; }
+void StartRead( ReadersWriter & mutex rw ) with(rw) {
+	if ( wcnt !=0 || ! is_empty( RWers ) ) wait( RWers, READER );
+	rcnt += 1;
+	if ( ! is_empty( RWers ) && front( RWers ) == READER ) signal( RWers );
+}
+void EndRead( ReadersWriter & mutex rw ) with(rw) {
+	rcnt -= 1;
+	if ( rcnt == 0 ) signal( RWers );
+}
+void StartWrite( ReadersWriter & mutex rw ) with(rw) {
+	if ( wcnt != 0 || rcnt != 0 ) wait( RWers, WRITER );
+	wcnt = 1;
+}
+void EndWrite( ReadersWriter & mutex rw ) with(rw) {
+	wcnt = 0;
+	signal( RWers );
+}
+int readers( ReadersWriter & rw ) { return rw.rcnt; }
+
+void Read( ReadersWriter & rw ) {
+	StartRead( rw );
+	sout | "Reader:" | active_thread() | ", shared:" | SharedRW | " with:" | readers( rw ) | " readers";
+	yield( 3 );
+	EndRead( rw );
+}
+void Write( ReadersWriter & rw ) {
+	StartWrite( rw );
+
+	SharedRW += 1;
+	sout | "Writer:" | active_thread() | ",  wrote:" | SharedRW;
+	yield( 1 );
+	EndWrite( rw );
+}
+
+thread Worker {
+	ReadersWriter &rw;
+};
+void ?{}( Worker & w, ReadersWriter * rw ) { &w.rw = rw; }
+void main( Worker & w ) with(w) {
+	for ( 10 ) {
+		if ( rand() % 100 < 70 ) {					// decide to be a reader or writer
+			Read( rw );
+		} else {
+			Write( rw );
+		} // if
+	} // for
+}
+
+int main() {
+	enum { MaxTask = 5 };
+	ReadersWriter rw;
+	Worker *workers[MaxTask];
+
+	for ( i; MaxTask ) workers[i] = new( &rw );
+	for ( i; MaxTask ) delete( workers[i] );
+	sout | "successful completion";
+} // main
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa -O2 RWMonitorINT.cfa" //
+// End: //
Index: doc/papers/concurrency/examples/channels.go
===================================================================
--- doc/papers/concurrency/examples/channels.go	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
+++ doc/papers/concurrency/examples/channels.go	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
@@ -0,0 +1,35 @@
+package main
+import "fmt"
+func main() {
+	type Msg struct{ i, j int }
+
+	ch1 := make( chan int )
+	ch2 := make( chan float32 )
+	ch3 := make( chan Msg )
+	hand := make( chan string )
+	shake := make( chan string )
+	gortn := func() { // thread starts
+		var i int;  var f float32;  var m Msg
+		L: for {
+			select { // wait for message
+			  case i = <- ch1: fmt.Println( i )
+			  case f = <- ch2: fmt.Println( f )
+			  case m = <- ch3: fmt.Println( m )
+			  case <- hand: break L // sentinel
+			}
+		}
+		shake <- "SHAKE" // completion
+	}
+
+	go gortn() // start thread
+	ch1 <- 0 // different messages
+	ch2 <- 2.5
+	ch3 <- Msg{1, 2}
+	hand <- "HAND" // sentinel value
+	<- shake // wait for completion
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "go run channels.go" //
+// End: //
Index: doc/papers/concurrency/examples/channels.rs
===================================================================
--- doc/papers/concurrency/examples/channels.rs	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
+++ doc/papers/concurrency/examples/channels.rs	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
@@ -0,0 +1,34 @@
+#![feature(async_await)]
+
+use std::thread;
+use std::sync::mpsc;
+
+fn main() {
+	let (tx1, rx1) = mpsc::channel();
+	let (tx2, rx2) = mpsc::channel();
+	let (tx3, rx3) = mpsc::channel();
+	let (tx4, rx4) = mpsc::channel();
+	struct Msg { i : i64,  j : i64 }
+	let th = thread::spawn( || {
+		let i : i64; let f : f64; let m : Msg;
+		loop {
+			select! {
+				i = rx1.recv() => println( i );
+				f = rx2.recv() => println( f );
+				m = rx3.recv() => println( m );
+				_ = rx4.recv() => break;
+			}
+		}
+	});
+
+	tx1.send( 0 ); // different messages
+	tx2.send( 2.5 );
+	tx3.send( Msg { i:1, j:2 } );
+	tx4.send( "done" );
+	th.join().unwrap();
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "rustc -C opt-level=3 channels.rs" //
+// End: //
Index: doc/papers/concurrency/examples/future.rs
===================================================================
--- doc/papers/concurrency/examples/future.rs	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
+++ doc/papers/concurrency/examples/future.rs	(revision b0795bebc0e389f1524fddfc7d31695fbea4c2e5)
@@ -0,0 +1,10 @@
+use futures::executor::block_on;
+
+async fn hello_world() {
+    println!("hello, world!");
+}
+
+fn main() {
+    let future = hello_world(); // Nothing is printed
+    block_on(future); // `future` is run and "hello, world!" is printed
+}
