Új hozzászólás Aktív témák
-
btotyi
tag
Például így :
package test;
class Szal extends java.lang.Thread {
volatile static boolean Stop = false;
// Primordial thread executes main()
public static void main(String args[]) throws InterruptedException {
// Create and start 2 threads
Szal thread1 = new Szal();
thread1.setPriority(1); // 1st thread at 1th non-RT priority
Szal thread2 = new Szal();
thread2.setPriority(1); // 2nd thread at 1th non-RT priority
thread1.start(); // start 1st thread to execute run()
thread2.start(); // start 2nd thread to execute run()
// Sleep for 10 seconds, then tell the threads to terminate
Thread.sleep(10 * 1000);
Stop = true;
}
public void run() { // Created threads execute this method
System.out.println(''Created thread'');
int count = 0;
for (; Stop != true;) { // continue until asked to stop
count++;
Thread.yield(); // yield to other thread
}
System.out.println(''Thread terminates. Loop count is '' + count);
}
}
forrás:[link]
Új hozzászólás Aktív témák
A topicot kiemeltem. Valaki nem akar egy nyitó hsz-t írni?:))
- BESZÁMÍTÁS! Gigabyte H610M i3 12100F 16GB DDR4 512GB SSD RX 6600 8GB Zalman Z1 Plus ADATA 600W
- GYÖNYÖRŰ iPhone 12 64GB Green -1 ÉV GARANCIA - Kártyafüggetlen, MS3052, 96% Akkumulátor
- Zebra ZP505 EPL hőpapíros címkenyomtató
- Xiaomi Redmi Note 10 Pro 128GB, Kártyafüggetlen, 1 Év Garanciával
- Gamer PC- Számítógép! Csere-Beszámítás! I3 10100F / RTX 2060 / 32GB DDR4 / 500GB SSD
Állásajánlatok
Cég: FOTC
Város: Budapest