Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add breakpoints to Runnable classes
    text
    copied!<p>My <code>while(true)</code> is only running once, so I'm trying to add breakpoints to see what's going on, but they never seem to be reached within my <code>run()</code>. I'm using IntelliJ. In the debugger there's a "Threads" tab. Do I need to do something in that tab like select the right thread in order for my breakpoint to be reached? I also see thread names and am wondering how I can find the right thread in this list.</p> <pre><code>public class MyClass extends ServerWorkflowProcess&lt;OtherClass&gt; { private ExecutorService executorService = Executors.newSingleThreadExecutor(); ... @Override public void bootup() { logger.info("Booting up: " + this); BackgroundProcess backgroundImpositioner = new BackgroundProcess(this.getCollection()); executorService.submit(backgroundImpositioner); } @Override public void shutdown() { executorService.shutdown(); } } </code></pre> <p><strong>Background process</strong></p> <pre><code>public class BackgroundProcess implements Runnable { protected volatile Logger logger = Logger.getLogger(BackgroundImpositioner.class.getName()); Collection&lt;ImpositionWorkstation&gt; impositionWorkstations; public BackgroundImpositioner(Collection&lt;ImpositionWorkstation&gt; impositionWorkstation) { this.impositionWorkstations = impositionWorkstation; } public void run() { while(true) { logger.info("looping"); for (ImpositionWorkstation workstation : impositionWorkstations) { if (workstation.canAcceptWork()) { //go do work in another thread so we're not blocking this workstation.getWorkFromQueue(); try { workstation.doWork(); } catch (ImpositionException e) { logger.severe(e.getMessage()); } } } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); logger.severe("Background impositioner was interrupted"); } } } } </code></pre> <p>Side note: the console shows "looping", so I know it gets executed once. The breakpoint never gets hit and it doesn't execute more than once.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload