Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
jb11.0 threads
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; import java.io.*; class Rextester { public static void main(String args[]) { System.out.println("начало выполнения основного потока"); MyThread mt = new MyThread("test thread 1"); Thread th = new Thread(mt); th.start(); try{ for(int i=0; i<15; i++){ Thread.sleep(100); mt.setDellay((100*(i+1))/2); //System.out.println("в основном потоке счётчик= " + i); System.out.print('.'); } }catch(InterruptedException exp){ System.out.println("Основной поток прерван."); } System.out.println("завершение основного потока"); } } class MyThread implements Runnable{ String _thrName; int _dellay; public MyThread(String thrName){ _thrName = thrName; _dellay = 100; } public void run(){ System.out.println(_thrName + " - запуск"); int tmpDel = 0; try{ for(int i=0; i<10; i++){ tmpDel = _dellay; Thread.sleep(tmpDel); System.out.println("|" + _thrName + " задержка = "+tmpDel+" счётчик = " + i); } }catch(InterruptedException exc){ System.out.println("Exception in " + _thrName + ": thread interrupt."); } System.out.println("Поток " + _thrName + " завершение."); } public void setDellay(int dellay){ _dellay = dellay; } }
run
|
edit
|
history
|
help
0
ABC`s
Votes JAVA
Find a dot in a string
sortArraymerge
Rakibul Haque
1.6
Find merge point of two linkedlists - solution 1
1a
Min Quadrato
Complex number multiplication (leetcode)