Note that there are some explanatory texts on larger screens.

plurals
  1. POPausing/resuming multiple threads in java
    text
    copied!<p>Trying to write a program that will run, suspend, and resume 3 threads. </p> <p>here's the coding:</p> <pre><code>class Connectthread implements Runnable { public void run() { for(int j=0;j&lt;90;j+=10) System.out.println("Connecting..." + j + " Secs"); } } class DLoadthread implements Runnable { public void run() { for(int d=0;d&lt;60;d+=10) System.out.println("Downloading..." + d + " Secs"); } } class Runthread implements Runnable { public void run() { for(int r=0;r&lt;120;r+=10) System.out.println("Running..." + r + " Secs"); } } class EHAunitThread { Connectthread ct=new Connectthread(); DLoadthread dt=new DLoadthread(); Runthread rt=new Runthread(); public void main(String arg[]) { //putting threads into ready state. System.out.print("Starting threads\n"); ct.start(); dt.start(); rt.start(); System.out.print("Sleeping 3 seconds\n"); safeSleep(3000, "Threads first sleep time interrupted\n"); System.out.print("Suspending threads\n"); ct.suspend(); dt.suspend(); rt.suspend(); System.out.print("Sleep 5 seconds\n"); safeSleep(5000, "Threads second sleep time interrupted\n"); System.out.print("Resume threads\n"); ct.resume(); dt.resume(); rt.resume(); try { ct.join(); dt.join(); rt.join(); } catch (InterruptedException e) { System.out.print("Join interrupted"); } System.out.print("Testcase Completed"); System.exit(0); } } </code></pre> <p>it keeps giving me 14 of these <code>error:cannot find symbol</code> messages when i try to compile it.</p> <p>To my knowledge, the coding <em>looks</em> correct as far as grammar is concerned. What am I doing wrong here?</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