Use a larger size of array with smaller values
This better illustrates the concurrent behavior
This commit is contained in:
		
							parent
							
								
									f1be1b1f32
								
							
						
					
					
						commit
						69daebdf66
					
				| 
						 | 
					@ -1,9 +1,7 @@
 | 
				
			||||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
<project version="4">
 | 
					<project version="4">
 | 
				
			||||||
  <component name="ChangeListManager">
 | 
					  <component name="ChangeListManager">
 | 
				
			||||||
    <list default="true" id="3da8c399-6d50-4f60-937d-4daa7aad4637" name="Default Changelist" comment="">
 | 
					    <list default="true" id="3da8c399-6d50-4f60-937d-4daa7aad4637" name="Default Changelist" comment="" />
 | 
				
			||||||
      <change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" />
 | 
					 | 
				
			||||||
    </list>
 | 
					 | 
				
			||||||
    <ignored path="$PROJECT_DIR$/out/" />
 | 
					    <ignored path="$PROJECT_DIR$/out/" />
 | 
				
			||||||
    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
 | 
					    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
 | 
				
			||||||
    <option name="SHOW_DIALOG" value="false" />
 | 
					    <option name="SHOW_DIALOG" value="false" />
 | 
				
			||||||
| 
						 | 
					@ -20,8 +18,8 @@
 | 
				
			||||||
      <file pinned="false" current-in-tab="true">
 | 
					      <file pinned="false" current-in-tab="true">
 | 
				
			||||||
        <entry file="file://$PROJECT_DIR$/src/Main.java">
 | 
					        <entry file="file://$PROJECT_DIR$/src/Main.java">
 | 
				
			||||||
          <provider selected="true" editor-type-id="text-editor">
 | 
					          <provider selected="true" editor-type-id="text-editor">
 | 
				
			||||||
            <state relative-caret-position="259">
 | 
					            <state relative-caret-position="356">
 | 
				
			||||||
              <caret line="54" selection-start-line="54" selection-end-line="54" />
 | 
					              <caret line="85" column="30" selection-start-line="85" selection-start-column="30" selection-end-line="85" selection-end-column="30" />
 | 
				
			||||||
              <folding>
 | 
					              <folding>
 | 
				
			||||||
                <element signature="imports" expanded="true" />
 | 
					                <element signature="imports" expanded="true" />
 | 
				
			||||||
              </folding>
 | 
					              </folding>
 | 
				
			||||||
| 
						 | 
					@ -101,16 +99,15 @@
 | 
				
			||||||
      <option name="number" value="Default" />
 | 
					      <option name="number" value="Default" />
 | 
				
			||||||
      <option name="presentableId" value="Default" />
 | 
					      <option name="presentableId" value="Default" />
 | 
				
			||||||
      <updated>1570414923071</updated>
 | 
					      <updated>1570414923071</updated>
 | 
				
			||||||
      <workItem from="1570414924458" duration="2937000" />
 | 
					      <workItem from="1570414924458" duration="3727000" />
 | 
				
			||||||
    </task>
 | 
					    </task>
 | 
				
			||||||
    <servers />
 | 
					    <servers />
 | 
				
			||||||
  </component>
 | 
					  </component>
 | 
				
			||||||
  <component name="TimeTrackingManager">
 | 
					  <component name="TimeTrackingManager">
 | 
				
			||||||
    <option name="totallyTimeSpent" value="2937000" />
 | 
					    <option name="totallyTimeSpent" value="3727000" />
 | 
				
			||||||
  </component>
 | 
					  </component>
 | 
				
			||||||
  <component name="ToolWindowManager">
 | 
					  <component name="ToolWindowManager">
 | 
				
			||||||
    <frame x="11" y="-6" width="1898" height="1051" extended-state="6" />
 | 
					    <frame x="11" y="-6" width="1898" height="1051" extended-state="6" />
 | 
				
			||||||
    <editor active="true" />
 | 
					 | 
				
			||||||
    <layout>
 | 
					    <layout>
 | 
				
			||||||
      <window_info id="Designer" />
 | 
					      <window_info id="Designer" />
 | 
				
			||||||
      <window_info id="UI Designer" />
 | 
					      <window_info id="UI Designer" />
 | 
				
			||||||
| 
						 | 
					@ -119,12 +116,12 @@
 | 
				
			||||||
      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
 | 
					      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
 | 
				
			||||||
      <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
 | 
					      <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
 | 
				
			||||||
      <window_info anchor="bottom" id="Version Control" />
 | 
					      <window_info anchor="bottom" id="Version Control" />
 | 
				
			||||||
      <window_info anchor="bottom" id="Terminal" weight="0.3290461" />
 | 
					      <window_info active="true" anchor="bottom" id="Terminal" visible="true" weight="0.3290461" />
 | 
				
			||||||
      <window_info anchor="bottom" id="Event Log" side_tool="true" />
 | 
					      <window_info anchor="bottom" id="Event Log" side_tool="true" />
 | 
				
			||||||
      <window_info anchor="bottom" id="Messages" weight="0.3290461" />
 | 
					      <window_info anchor="bottom" id="Messages" weight="0.3290461" />
 | 
				
			||||||
      <window_info anchor="bottom" id="Message" order="0" />
 | 
					      <window_info anchor="bottom" id="Message" order="0" />
 | 
				
			||||||
      <window_info anchor="bottom" id="Find" order="1" />
 | 
					      <window_info anchor="bottom" id="Find" order="1" />
 | 
				
			||||||
      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.3290461" />
 | 
					      <window_info anchor="bottom" id="Run" order="2" weight="0.3290461" />
 | 
				
			||||||
      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
 | 
					      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
 | 
				
			||||||
      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
 | 
					      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
 | 
				
			||||||
      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
 | 
					      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
 | 
				
			||||||
| 
						 | 
					@ -143,8 +140,8 @@
 | 
				
			||||||
  <component name="editorHistoryManager">
 | 
					  <component name="editorHistoryManager">
 | 
				
			||||||
    <entry file="file://$PROJECT_DIR$/src/Main.java">
 | 
					    <entry file="file://$PROJECT_DIR$/src/Main.java">
 | 
				
			||||||
      <provider selected="true" editor-type-id="text-editor">
 | 
					      <provider selected="true" editor-type-id="text-editor">
 | 
				
			||||||
        <state relative-caret-position="259">
 | 
					        <state relative-caret-position="356">
 | 
				
			||||||
          <caret line="54" selection-start-line="54" selection-end-line="54" />
 | 
					          <caret line="85" column="30" selection-start-line="85" selection-start-column="30" selection-end-line="85" selection-end-column="30" />
 | 
				
			||||||
          <folding>
 | 
					          <folding>
 | 
				
			||||||
            <element signature="imports" expanded="true" />
 | 
					            <element signature="imports" expanded="true" />
 | 
				
			||||||
          </folding>
 | 
					          </folding>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@ import java.util.ArrayList;
 | 
				
			||||||
import java.util.concurrent.atomic.AtomicInteger;
 | 
					import java.util.concurrent.atomic.AtomicInteger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Main {
 | 
					public class Main {
 | 
				
			||||||
    static int SIZE = 4;
 | 
					    static int SIZE = 40;
 | 
				
			||||||
    int [][] a;
 | 
					    int [][] a;
 | 
				
			||||||
    int [][] b;
 | 
					    int [][] b;
 | 
				
			||||||
    int [][] c;
 | 
					    int [][] c;
 | 
				
			||||||
| 
						 | 
					@ -32,12 +32,12 @@ public class Main {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int row = 0; row < SIZE; row++) {
 | 
					        for (int row = 0; row < SIZE; row++) {
 | 
				
			||||||
            for (int col = 0; col < SIZE; col++) {
 | 
					            for (int col = 0; col < SIZE; col++) {
 | 
				
			||||||
                a[row][col] = random.nextInt(10);
 | 
					                a[row][col] = random.nextInt(2);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        for (int row = 0; row < SIZE; row++) {
 | 
					        for (int row = 0; row < SIZE; row++) {
 | 
				
			||||||
            for (int col = 0; col < SIZE; col++) {
 | 
					            for (int col = 0; col < SIZE; col++) {
 | 
				
			||||||
                b[row][col] = random.nextInt(10);
 | 
					                b[row][col] = random.nextInt(2);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,6 +48,7 @@ public class Main {
 | 
				
			||||||
                workingOn.set(0, workingOn.get(0) + 1);
 | 
					                workingOn.set(0, workingOn.get(0) + 1);
 | 
				
			||||||
                System.out.println("Start thread " + row);
 | 
					                System.out.println("Start thread " + row);
 | 
				
			||||||
                new Thread(new Worker(row)).start();
 | 
					                new Thread(new Worker(row)).start();
 | 
				
			||||||
 | 
					                Thread.yield();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
                while (workingOn.get(0) + workingOn.get(1) != 0) {
 | 
					                while (workingOn.get(0) + workingOn.get(1) != 0) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue