I've been following various example code I've found online, but no matter 
how I rearrange it, I can't seem to get a simple scheduler example to work.


This is my current code:


object Concurrency extends Loggable {
  private val system = ActorSystem("system", defaultExecutionContext = 
Some(ExecutionContexts.fromExecutor(Executors.newCachedThreadPool())))
  import system.dispatcher
  private val scheduler = system.scheduler

  Log.warn("starting up actor system")

  def runNow(f: => () => Unit):Unit =
    Future {f()}

  def scheduleOnce(duration:FiniteDuration, f: => () => Unit):Unit = {
    scheduler.scheduleOnce(duration)(() => runNow(f))
  }

  runNow(() => Log.warn("runNow works"))
  scheduleOnce(FiniteDuration(3,TimeUnit.SECONDS),() => 
Log.warn("scheduleOnce works"))
}

When I run this, I see my "runNow works" go off, but not my "scheduleOnce". 
What am I missing?

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to