Concurrent programming in javascript