Tutorial Addendum On Java - Accoutrement

travelappsios lifestyleappsios utilitiesappsios
 31 December 18:00   

    



    



    

Output

    

 

    

Priority: (min, norm, max) = (1, 5, 10)

    

Threads: 0 1 2 3 4 Time

    

Steps: 1527 2229 161931 31864 29386 17416

    

Steps: 3193 3881 175188 44342 41757 20301

    

Steps: 6499 5536 204244 74234 71608 27221

    

Steps: 8164 10495 244791 114110 112329 36475

    

Steps: 11491 10495 257239 142209 139702 43025

    

Steps: 13157 13805 285516 154633 152887 45909

    

Steps: 14820 15458 297916 167948 165368 48793

    

Steps: 16484 18763 327732 197825 195242 59009

    

Steps: 19817 22073 369925 239372 236753 65448

    

Steps: 23150 23729 403986 273273 271592 73410

    

Steps: 26482 27018 416407 286531 284058 76295

    

Steps: 28127 27018 429632 298998 296468 79299

    

Steps: 29794 31993 473677 343808 341381 89575

    

Steps: 33118 33662 486954 371226 368753 95944

    

Steps: 34780 35317 514379 397811 395301 102193

    

Steps: 38109 38639 541010 410201 408616 104958

    

Steps: 39770 40305 553411 423504 421101 111027

    

Steps: 41433 43640 595710 465923 463501 117757

    

Steps: 44763 45310 609007 478306 493386 124557

    

Steps: 48096 46980 638029 508055 519042 130686

    

Steps: 49759 50313 664613 533784 531442 133570

    

Steps: 51424 53649 690265 560371 558010 139639

    

Steps: 53090 53649 720171 589434 587953 146550

    

Steps: 58088 58656 751803 620981 619626 157366

    

Steps: 64759 65335 819279 688363 687045 169324

    

Steps: 68092 70339 865085 734088 732079 183085

    

Steps: 74763 73680 914229 783060 782025 191217

    

Steps: 78097 78691 958380 827074 826209 201372

    

Steps: 81431 82033 999999 871975 870174 211036

    

Steps: 86439 87032 999999 924273 923406 219149

    

Steps: 91446 92023 999999 999999 999999 230506

    

Steps: 91446 93361 999999 999999 999999 230626

    

Steps: 91446 94721 999999 999999 999999 230726

    

Steps: 91446 96091 999999 999999 999999 230826

    

Abolish accumulation job (Y/N)? y

    



    



    

First, a brace of addendum on the program design:

    



        

  • 5 sub-threads are created to do the aforementioned section of plan at anniversary step. Accomplish are

        

    repeated for 1000000 times.

        



  •     

  • That aforementioned section of plan is to calculation how some prime numbers are there beneath

        

    100.

        



  •     

  • The first sub-thread is accustomed the everyman priority, the additional sub-thread is given

        

    the average priority, and the blow 3 sub-threads are accustomed the accomplished priority.

        



  •     

  • Each sub-thread is recording the amount of accomplish it has accomplished so far at the

        

    end of anniversary step.

        



  •     

  • The capital cilia is again blockage the recording arrangement to see the

        

    execution advance of anniversary sub-threads.

        



  •     

  • The expire time in milliseconds is aswell appear anniversary time the capital thread

        

    is blockage the recording array.

        



  •     

  • Each sub-thread is articular by an basis amount accustomed in the architect with

        

    the advice of a changeless variable: t_last.

        



  •     

  • The changeless variable, n_prime, is adapted by all 5 sub-threads again with

        

    the aforementioned value. I don t accord any account to book out the amount of n_prime

        

    to verify the accuracy, but I did analysis the definiteness of my prime number

        

    counting algorithm in a separate program.

        



  •     

  • The capital cilia will never end by itself. You charge to columnist Ctrl-C to terminate

        

    the program.

        



  •     



    



    

Here is what I get out of the achievement of the program:

    



        

  • Threads with the altered antecedence levels may get the aforementioned bulk of

        

    processing time share. See the progresses of cilia 0 and 1. Cilia 0 had

        

    priority 1, and cilia 1 had antecedence 5. But they showed about the aforementioned

        

    progress rate.

        



  •     

  • Thread of antecedence 1 was accepting about 10 times beneath bulk of the processing

        

    time allotment than cilia of antecedence 10. See the advance ante of cilia 0 and

        

    thread 4.

        



  •     

  • The capital cilia was active at atomic 20 times slower if all 5 sub-threads

        

    were running. See the expire time intervals, which were > 2000 milliseconds while

        

    all 5 sub-threads were running. The sleeping time was about 100 milliseconds.

        

    So the capital cilia was blocked for at atomic 1900 milliseconds.

        



  •     



    



    

Another absorbing behavior was noticed while active the program. While all 5

    

sub-threads were running, the operating arrangement was actual sluggish. I was alone able

    

to move the abrasion arrow around. Beat on windows of any additional active appliance

    

programs gave me no acknowledgment at all until 3 sub-threads accomplished the end.

    

I assumption the cause for this behavior is that Windows 2000 arrangement is not absolutely sharing

    

processing time apartof the active appliance programs equally. It let my Java

    

application program (running beneath Java VM) took 100% of the CPU processing time.

    

This is not a well-designed time-sharing multi-tasking operating system.

    

Can anyone try my program a Unix system?

    



    

Sharing Data

    



    

Threads of the aforementioned active program not alone allotment CPU time, they aswell allotment

    

the aforementioned anamnesis amplitude that allocated to the program. This is altered than

    

multiple programs active at the operating arrangement level, area anamnesis amplitude

    

can not be aggregate by altered active programs.

    



    

Sharing the aforementioned anamnesis amplitude apartof some accoutrement is a actual nice feature.

    

It allows accoutrement alive on the aforementioned set of data to achieve a big task

    

together. But it can aswell be a agitation maker, because the beheading speed

    

of anniversary cilia can not be managed. There is no way to understand which thread

    

is the first one to ability the data, and which one will be the next one.

    



    

 


Tags: program, programs, times, system, different, application, operating, space, recording, memory, prime, notes, progress

 steps, thread, threads, running, program, priority, system, programs, share, milliseconds, sharing, space, memory, operating, application, progress, prime, times, given, recording, notes, different, , 999999 999999, sub threads, main thread, sub thread, steps 91446, memory space, threads were, operating system, 999999 999999 999999, threads were running, running application programs, sub threads were,

Share Tutorial Addendum On Java - Accoutrement:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  java