File tree Expand file tree Collapse file tree
Past Papers/Mock paper Answers-20211018/Mock Esay Answers/Designpattern3 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414 <natures >
1515 <nature >org.eclipse.jdt.core.javanature</nature >
1616 </natures >
17+ <filteredResources >
18+ <filter >
19+ <id >1664908487928</id >
20+ <name ></name >
21+ <type >30</type >
22+ <matcher >
23+ <id >org.eclipse.core.resources.regexFilterMatcher</id >
24+ <arguments >node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments >
25+ </matcher >
26+ </filter >
27+ </filteredResources >
1728</projectDescription >
Original file line number Diff line number Diff line change 1414 <natures >
1515 <nature >org.eclipse.jdt.core.javanature</nature >
1616 </natures >
17+ <filteredResources >
18+ <filter >
19+ <id >1664908487944</id >
20+ <name ></name >
21+ <type >30</type >
22+ <matcher >
23+ <id >org.eclipse.core.resources.regexFilterMatcher</id >
24+ <arguments >node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments >
25+ </matcher >
26+ </filter >
27+ </filteredResources >
1728</projectDescription >
Original file line number Diff line number Diff line change 1+ public class ThreadJoin extends Thread {
2+
3+ public void run () {
4+
5+ Thread t = Thread .currentThread ();
6+ System .out .println ("Started Executing " +t .getName ());
7+
8+ for (int i =0 ; i <10 ; i ++) {
9+
10+ System .out .println (t .getName () + i );
11+
12+ }
13+
14+ System .out .println ("Finished Executing " +t .getName ());
15+
16+ }
17+
18+ public static void main (String [] args ) throws Exception {
19+
20+ Thread t = new Thread (new ThreadJoin (), "New Thread" );
21+ t .start ();
22+ System .out .println ("Started executing main thread" );
23+
24+ t .join ();
25+
26+
27+ for (int i =0 ; i <10 ; i ++) {
28+
29+ System .out .println (Thread .currentThread ().getName () +i );
30+
31+ }
32+
33+ System .out .println ("Finished Executing " +Thread .currentThread ().getName ());
34+
35+ }
36+
37+
38+ }
Original file line number Diff line number Diff line change 1+ public class ThreadNotifyTest {
2+
3+ public static void main (String args []) {
4+
5+ ThreadNotifyTest threadnotifytest = new ThreadNotifyTest ();
6+
7+ Thread t1 = new Thread1 (threadnotifytest , "New Thread1" );
8+ Thread t2 = new Thread2 (threadnotifytest , "New Thread2" );
9+ Thread t3 = new Thread3 (threadnotifytest , "New Thread3" );
10+
11+ t1 .start ();
12+ t2 .start ();
13+ t3 .start ();
14+
15+
16+
17+
18+
19+ }
20+
21+
22+
23+
24+ }
Original file line number Diff line number Diff line change 1+ public class ThreadYield extends Thread {
2+
3+ public void run () {
4+
5+ Thread t = Thread .currentThread ();
6+ System .out .println ("Started Executing " +t .getName ());
7+
8+ for (int i =0 ; i <10 ; i ++) {
9+
10+ System .out .println (t .getName () + i );
11+
12+ }
13+
14+ System .out .println ("Finished Executing " +t .getName ());
15+
16+ }
17+
18+ public static void main (String args []) throws Exception {
19+
20+ Thread t = new Thread (new ThreadYield (),"New Thread" );
21+ t .start ();
22+
23+ System .out .println ("Started executing main thread" );
24+
25+ t .yield ();
26+
27+ for (int i = 0 ; i <10 ; i ++) {
28+
29+ System .out .println (Thread .currentThread ().getName () +i );
30+
31+ }
32+
33+ System .out .println ("Finished Executing " +Thread .currentThread ().getName ());
34+
35+
36+ }
37+
38+
39+
40+ }
Original file line number Diff line number Diff line change 1414 <natures >
1515 <nature >org.eclipse.jdt.core.javanature</nature >
1616 </natures >
17+ <filteredResources >
18+ <filter >
19+ <id >1664908487937</id >
20+ <name ></name >
21+ <type >30</type >
22+ <matcher >
23+ <id >org.eclipse.core.resources.regexFilterMatcher</id >
24+ <arguments >node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments >
25+ </matcher >
26+ </filter >
27+ </filteredResources >
1728</projectDescription >
You can’t perform that action at this time.
0 commit comments