Application Data Shared by Multiple Threads - Test Results

This section provides test results of a tutorial example on how to share application data by multiple threads. Data sharing allows multiple threads to work together on a single large task.

I performed several tests with the program presented in the previous section. Testing outputs are listed below.

Output of 1 thread:

Thread: 0
  Year: 0
  Year: 2001
  Year: 2025
  Year: 2044
  Year: 2077
  Year: 2112
  ......
  Year: 3824
  Year: 3859
  Year: 3895
  Year: 3930
  Year: 3966
  Year: 3999
Time = 6029
Year, Threads

Output of 5 threads:

Thread: 0 1 2 3 4
  Year: 0 0 0 0 0
  Year: 2039 2040 2043 2042 2044
  Year: 2067 2040 2048 2042 2044
  Year: 2124 2142 2048 2159 2044
  Year: 2318 2180 2230 2300 2044
  Year: 2353 2325 2230 2300 2335
  Year: 2520 2526 2230 2529 2335
  Year: 2644 2741 2641 2723 2335
  Year: 2758 2792 2641 2723 2776
  Year: 3128 3124 2952 3096 3139
  Year: 3181 3216 2952 3252 3213
  Year: 3689 3667 3559 3605 3657
  Year: 3992 3999 3999 3999 3999
  Year: 3999 3999 3999 3999 3999
Time = 6369
Year, Threads

Output of 10 threads:

Thread: 0 1 2 3 4 5 6 7 8 9
  Year: 2936 2948 3237 3242 3208 2954 3182 3232 3169 2963
  Year: 2936 3303 3237 3242 3208 3272 3182 3232 3169 2963
  Year: 3495 3498 3237 3480 3974 3890 3996 3999 3999 2963
  Year: 3999 3999 3999 3999 3999 3999 3999 3999 3999 3999
Time = 3925
Year, Threads

Output of 10 threads - another run:

Thread: 0 1 2 3 4 5 6 7 8 9
  Year: 2222 2239 2174 2275 2245 2142 2213 0 0 2248
  Year: 2531 2283 2501 2510 2245 2142 2213 2460 2521 2470
  Year: 2531 2283 2583 2624 2547 2142 2213 2460 2556 2615
  Year: 2531 2283 2651 2624 2691 2142 2679 2460 2556 2615
  Year: 3011 2781 2651 2814 3017 3047 2955 2913 3020 2741
  Year: 3438 2781 3102 3204 3017 3337 3149 3396 3361 3426
  Year: 3504 2781 3102 3204 3466 3337 3522 3396 3361 3426
  Year: 3679 3670 3555 3204 3642 3337 3625 3396 3655 3426
  Year: 3908 3949 3890 3978 3937 3991 3625 3396 3745 3426
  Year: 3999 3999 3999 3999 3999 3999 3999 3999 3999 3999
Time = 6750
Year, Threads

Output of 15 threads:

Thread: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
  Year: 2039 2046 2053 0 0 0 0 0 0 0 0 2284 2363 2425 2387
  Year: 2212 2499 2088 0 0 0 0 0 0 0 0 2284 2489 2461 2387
  Year: 2638 2655 2088 0 0 0 0 2615 2663 2645 2602 2630 2489 2461 2387
  Year: 3441 2885 2088 2921 3430 3169 3487 2903 3362 3222 3186 3499 3192
     3201 3154
  Year: 3996 3841 3502 3836 3611 3815 3999 3501 3362 3993 3900 3885 3927
     3824 3876
  Year: 3999 3999 3999 3999 3999 3999 3999 3999 3999 3999 3999 3999 3999
     3999 3999
Time = 6920
Year, Threads

A couple of interesting notes on the results:

Last update: 2014.

Table of Contents

 About This Book

 Installing JDK 1.8 on Windows

 Execution Process, Entry Point, Input and Output

 Primitive Data Types and Literals

 Bits, Bytes, Bitwise and Shift Operations

 Managing Bit Strings in Byte Arrays

 Reference Data Types and Variables

 StringBuffer - The String Buffer Class

 System Properties and Runtime Object Methods

 Generic Classes and Parameterized Types

 Generic Methods and Type Inference

 Lambda Expressions and Method References

Execution Threads and Multi-Threading Java Programs

 What Are Processes and Threads?

 The "Thread" Class - Creating Thread Objects With Thread Sub Classes

 The "Runnable" Interface - Creating Thread Objects with Runnable Objects

 CPU Execution Time Shared by Multiple Threads

 CPU Execution Time Shared by Multiple Threads - Test Output

 Application Data Shared by Multiple Threads

Application Data Shared by Multiple Threads - Test Results

 interrupt() - Method to Terminate Thread

 ThreadGroup Class and "system" ThreadGroup Tree

 Synchronization Technique and Synchronized Code Blocks

 Deadlock Condition Example Programs

 Garbage Collection and the gc() Method

 Outdated Tutorials

 References

 PDF Printing Version