Skip to content

Instantly share code, notes, and snippets.

@a18simongv
Last active January 2, 2019 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a18simongv/10aee9e4e96d8393fe8c45621b6fc7c7 to your computer and use it in GitHub Desktop.
Save a18simongv/10aee9e4e96d8393fe8c45621b6fc7c7 to your computer and use it in GitHub Desktop.
package runnableCase;
public class Program {
public static void main(String[] args) throws Exception{
RunnableExample runn = new RunnableExample();
Thread thread = new Thread(runn);
thread.start();
for(int i=0; i<10; i++) {
System.out.println(i + ": No");
Thread.sleep((int) (Math.random()*1000));
}
}
}
class RunnableExample implements Runnable{
@Override
public void run() {
for(int i=0; i<10; i++) {
System.out.println(i + ": Si");
try {
Thread.currentThread().sleep((int) (Math.random()*1000));
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment