Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This code works in version 2.11, but don't work in version 2.12 and 2.13. #11836

Closed
yunfan123 opened this issue Dec 24, 2019 · 1 comment
Closed

Comments

@yunfan123
Copy link

yunfan123 commented Dec 24, 2019

scala> :paste
// Entering paste mode (ctrl-D to finish)

import java.util.concurrent.{ExecutorService, Executors}

  import scala.concurrent.duration.Duration
  import scala.concurrent.{Await, ExecutionContext, ExecutionContextExecutor, Future}
  import scala.util.{Failure, Success}

  val pool: ExecutorService = Executors.newFixedThreadPool(10)

  implicit val ec: ExecutionContextExecutor =
    ExecutionContext.fromExecutorService(pool)


  def ff(i: Int): Future[Int] = Future{
    println(i)
    Thread.sleep(i * 100)
    println(i)
    i
  }

  val futures: List[Future[Int]] = (1 to 10).map(i => ff(i)).toList
  val f = Future.sequence(futures) andThen {
    case Success(_) =>
      println("All OK")
  }
  println("Before ready")
  Await.ready(f, Duration.Inf)
  println("After ready")
  pool.shutdown()


// Exiting paste mode, now interpreting.

In scala 2.12 or 2.13 (with java 8) paste mode, it just print Before ready.
But it works fine in 2.11 paste mode.

@SethTisue
Copy link
Member

almost certainly a duplicate of #9076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants