From cac65ef755f6ed941932e41da34de428ab9cd943 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 24 Apr 2018 11:07:33 +0100 Subject: [PATCH] Print a useful debug log if we cannot safely terminate a task --- .../core/computer/ComputerThread.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java index d97166ce5..43be5fa4e 100644 --- a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java +++ b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java @@ -224,6 +224,23 @@ private void execute( BlockingQueue queue ) throws InterruptedException // Interrupt the thread if( !done ) { + StringBuilder builder = new StringBuilder( "Terminating " ); + if( computer != null ) + { + builder.append( "computer " ).append( computer.getID() ); + } + else + { + builder.append( "unknown computer" ); + } + + builder.append( ". Thread is currently running" ); + for( StackTraceElement element : thread.getStackTrace() ) + { + builder.append( "\n at " ).append( element ); + } + ComputerCraft.log.error( builder.toString() ); + thread.interrupt(); thread = null; runner = null;