File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/main/java/multithread Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ package multithread ;
2
+
3
+ public class OneThreadDemo {
4
+ static class MeaninglessClass {
5
+ public void meaninglessMethod () {
6
+ System .out .println ("In meaninglessMethod method now, current thread name is: " + Thread .currentThread ().getName ());
7
+ }
8
+ }
9
+
10
+ public static void main (String ... args ) {
11
+ /**This is to show that this program will guarantee to run in just one thread: main, there's no multi-threading here.*/
12
+ MeaninglessClass meaninglessClass = new MeaninglessClass ();
13
+ meaninglessClass .meaninglessMethod ();
14
+ meaninglessClass .meaninglessMethod ();
15
+ meaninglessClass .meaninglessMethod ();
16
+ meaninglessClass .meaninglessMethod ();
17
+ meaninglessClass .meaninglessMethod ();
18
+ System .out .println ("Program finished." );
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments