检查Scala中的线程是否是新的?

时间:2015-03-19 02:47:07

标签: java multithreading scala

似乎Thread.State.NEW崩溃了我的Scala REPL。如何正确测试线程是否已启动?

scala> Thread.State.NEW
ReplGlobal.abort: Unknown type: <notype>(NEW), <notype> [class scala.reflect.internal.Types$UniqueConstantType, class scala.reflect.internal.Types$NoType$] TypeRef? false
error: Unknown type: <notype>(NEW), <notype> [class scala.reflect.internal.Types$UniqueConstantType, class scala.reflect.internal.Types$NoType$] TypeRef? false
scala.reflect.internal.FatalError: Unknown type: <notype>(NEW), <notype> [class scala.reflect.internal.Types$UniqueConstantType, class scala.reflect.internal.Types$NoType$] TypeRef? false
    at scala.reflect.internal.Reporting$class.abort(Reporting.scala:59)
    at scala.tools.nsc.interpreter.IMain$$anon$1.scala$tools$nsc$interpreter$ReplGlobal$$super$abort(IMain.scala:237)
    at scala.tools.nsc.interpreter.ReplGlobal$class.abort(ReplGlobal.scala:20)
    at scala.tools.nsc.interpreter.IMain$$anon$1.abort(IMain.scala:237)
    at scala.tools.nsc.backend.icode.TypeKinds$class.toTypeKind(TypeKinds.scala:401)
    at scala.tools.nsc.backend.icode.ICodes.toTypeKind(ICodes.scala:19)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadLiteral$1(GenICode.scala:907)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:911)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genStat(GenICode.scala:170)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:155)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:155)
    at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:110)
    at scala.collection.immutable.List.foldLeft(List.scala:83)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:915)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:123)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:71)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:148)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:98)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:71)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:89)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:67)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.apply(GenICode.scala:63)
    at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:410)
    at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:377)
    at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:377)
    at scala.collection.Iterator$class.foreach(Iterator.scala:743)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1177)
    at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:377)
    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.run(GenICode.scala:55)
    at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1557)
    at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1542)
    at scala.tools.nsc.Global$Run.compileSources(Global.scala:1537)
    at scala.tools.nsc.interpreter.IMain.compileSourcesKeepingRun(IMain.scala:391)
    at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compileAndSaveRun(IMain.scala:807)
    at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compile(IMain.scala:766)
    at scala.tools.nsc.interpreter.IMain$Request.compile$lzycompute(IMain.scala:942)
    at scala.tools.nsc.interpreter.IMain$Request.compile(IMain.scala:937)
    at scala.tools.nsc.interpreter.IMain.compile(IMain.scala:534)
    at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:522)
    at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:520)
    at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:754)
    at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:799)
    at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:666)
    at scala.tools.nsc.interpreter.ILoop.processLine(ILoop.scala:433)
    at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:450)
    at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:868)
    at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:854)
    at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:854)
    at scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:95)
    at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:854)
    at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74)
    at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
    at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
    at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

That entry seems to have slain the compiler.  Shall I replay
your session? I can re-run each line except the last one.
[y/n]
Abandoning crashed session.

0 个答案:

没有答案