Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
public class Main { public static void main(String[] args) { t t1 = new t(1); t t2 = new t(2); t1.start(); t2.start(); try { // t1.join(); if(t1.isAlive()) { System.out.println("Thread 1 interrupted!"); t1.interrupt(); } // t2.join(); if(t2.isAlive()) { t2.interrupt(); System.out.println("Thread 2 interrupted"); } } catch (Exception ex) { ex.printStackTrace(); } } } class t extends Thread { int id; public t(int _id) { id = _id; } @Override public void run() { for(int i = 0; i < 10; i++) { System.out.println("Thread " + id + " " + i); try { // Thread.sleep(100); } catch (Exception ex) { ex.printStackTrace(); } } } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)