Skip to content

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

Closed
@yunfan123

Description

@yunfan123
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions