lang:java:thread
                Ceci est une ancienne révision du document !
Table des matières
Threads
Runnable
public class T implements Runnable { public void run() { } } public static void main(String[] args) { Thread t1 = new Thread(new T()); t1.start(); }
Thread
public class T extends Thread { public void run() { } } public static void main(String[] args) { T t1 = new T(); t1.start(); }
Méthodes courantes
void start(): éligibilitévoid run(): instructions du Threadvoid interrupt(): arrêt programméboolean interrupted(): thread arrêté ?void stop(): déprécié au profit deinterrupt()static void sleep(long ms): arrêt pendant un certain tempsstatic native Thread currentThread()
Accès concurrent
class C { synchronized void p(){ } }
est équivalent à
class C { void p() { synchronized (this){ } } }
Le concept consiste à poser un lock sur une instance ou sur une classe.
lang/java/thread.1569776485.txt.gz · Dernière modification :  de root
                
                