File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
src/main/java/challenge31_40 Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ package challenge31_40 ;
2+
3+ /**
4+ * Daemon thread : https://stackoverflow.com/questions/2213340/what-is-a-daemon-thread-in-java
5+ * is a thread that does not prevent the JVM from exiting.
6+ * an example of a daemon thread is the garbage collector.
7+ */
8+ public class Challenge_35 {
9+ private static int nummer = 10 ;
10+ public static void main ( String [] args ) {
11+ new MotorCycle ("Harley Davidson" ).start ();
12+
13+ MotorCycle motorCycle = new MotorCycle ("Dodge Tomahawk" );
14+ motorCycle .setPriority (Thread .MAX_PRIORITY );
15+ motorCycle .setDaemon (true );
16+ motorCycle .start ();
17+
18+ MotorCycle yamaha = new MotorCycle ("Yamaha" );
19+ yamaha .setPriority (Thread .MIN_PRIORITY );
20+ yamaha .setDaemon (true );
21+ yamaha .start ();
22+ }
23+ static class MotorCycle extends Thread {
24+ public MotorCycle ( String name ) {
25+ super (name );
26+ }
27+
28+ @ Override
29+ public void run () {
30+ nummer ++;
31+ if (nummer ==13 )
32+ System .out .println (this .getName ());
33+ }
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments