File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/me/ramswaroop/threads Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 22
33/**
44 * Created by IntelliJ IDEA.
5+ * <p/>
6+ * Question: Print first name and last name (in order) using two different threads multiple times.
57 *
6- * Question: Print first name and last name (in order) using two different threads multiple times.
7- *
88 * @author: ramswaroop
99 * @date: 10/6/15
1010 * @time: 7:10 PM
@@ -54,6 +54,12 @@ public void printNameUsingMultipleThreads() {
5454 Thread firstThread = new Thread (printFirstName );
5555 Thread secondThread = new Thread (printLastName );
5656
57+ /**
58+ * Starting secondThread first so that secondThread starts waiting before the firstThread
59+ * calls notify(). But this behavior is not guaranteed as you cannot be 100% sure that
60+ * secondThread will actually run before firstThread (though it may run before most of the
61+ * time).
62+ */
5763 secondThread .start ();
5864 firstThread .start ();
5965 }
You can’t perform that action at this time.
0 commit comments