Thread CrearEventoHilo = new Thread(){
public void run(){
//do something that retrun "Calling this from your main thread can lead to deadlock"
}
};
CrearEventoHilo.start();
CrearEventoHilo.interrupt ();
public class Foo {
MyThread mTh;
void cantBeBothered() {
mTh = new MyThread( /*...*/ );
mTh.run();
mTh.start();
}
void imFinishedNowWaitingForThread() {
mTh.join();
}
void imOutKillingOffPendingThread() {
mTh.interrupt();
}
// .....
private class MyThread extends Thread {
// ...;
MyThread( /*...*/) {
// this... = ...;
}
public void run() {
doSomething( /*this...*/ );
}
}
}
задан kealist 6 March 2019 в 13:45
поделиться