write and run javascript as Thread