Skip to content

Instantly share code, notes, and snippets.

@dwhitney
Created July 5, 2011 21:02
Show Gist options
  • Select an option

  • Save dwhitney/1065921 to your computer and use it in GitHub Desktop.

Select an option

Save dwhitney/1065921 to your computer and use it in GitHub Desktop.
def main(args: Array[String]): Unit = {
import java.util.concurrent._
import scala.util.Random._
val executor = Executors.newFixedThreadPool(2)
for(_ <- 1 to 10000){
executor.submit(new Runnable(){
def run = {
if(nextInt(2) % 2 == 0) Bank.transfer("from", "to", nextInt(50))
else Bank.transfer("to", "from", nextInt(50))
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment