Skip to content

Instantly share code, notes, and snippets.

@francisl
Created November 23, 2012 22:01
Show Gist options
  • Save francisl/4137490 to your computer and use it in GitHub Desktop.
Save francisl/4137490 to your computer and use it in GitHub Desktop.
try server with threads
(define (start-threaded-server)
(display "starting server ")
(write-line (number->string x))
(set! x (+ x 1))
(let ((t (make-thread (lambda ()
(with-exception-handler
(lambda (exn)
(begin
(thread-sleep! 1)
(display ((condition-property-accessor 'exn 'location) exn))
(newline)
(single-server *tcp-connection*)))
(single-server *tcp-connection*))))))
(thread-start! t)))
(start-threaded-server)
(start-threaded-server)
(start-threaded-server)
(start-threaded-server)
(define key "")
(define (wait-loop)
(set! key (read-line))
(if (not (equal? key "q"))
(wait-loop))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment