so i got this little test program to simulate a word processor... sorta ... off a single processor i dont really want to post the code cuz it's a school assignment but i dont think it's necessary anyway
anyway i'm thinking about the thread.setPriority method
when i run all 4 threads at the same priority (Thread.NORM_PRIORITY) they of course run sequentially 1 2 3 4 1 2 3 4 etc
but i want the wp thread to be the highest priority and i want the gui thread to always finish last no matter what so i changed them as you can see
now i get more or less what i expect in that the wp thread runs, then the DS thread and then the other two
MY QUESTION IS: Why with this new scheme does the DS thread begin interupting the printer thread after a while?
edit... and why when i chage priorities from 1,5,10 to 1,2,3 does the output change so much?
Code
Output with normal priorities
Gui Poll
WPA
DS20
DS40
DS60
Print Line 1 characters 1 through 60
Print Line 2 characters 60 through 120
Print Line 3 characters 120 through 180
Print Line 4 characters 180 through 240
Print Line 5 characters 240 through 300
Print Line 6 characters 300 through 360
Gui Poll
WPA
DS80
DS100
DS120
Print Line 7 characters 360 through 420
Print Line 8 characters 420 through 480
Print Line 9 characters 480 through 540
Print Line 10 characters 540 through 600
Print Line 11 characters 600 through 660
Print Line 12 characters 660 through 720
//etcetcetc continues til they run out
Code
"C:\Program Files\Java\jdk1.8.0_77\bin\java" -Didea.launcher.port=7541 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.2.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_77\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_77\jre\lib\rt.jar;C:\Users\user\IdeaProjects\CSC406\out\production\CSC406;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.2.2\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain Main
WPA
WPA
... repeated for a while til it does it as many times as i told it to
WPA
WPA
WPA
WPA
WPA
DS20
DS40
DS60
DS80
DS100
DS120
DS140
DS160
DS180
DS200
DS220
DS240
DS260
DS280
DS300
DS320
DS340
DS360
DS380
DS400
DS420
DS440
DS460
DS480
DS500
DS520
DS540
DS560
DS580
DS600
DS620
DS640
DS660
DS680
DS700
DS720
DS740
DS760
DS780
DS800
DS820
DS840
DS860
DS880
DS900
DS920
DS940
DS960
DS980
DS1000
DS1020
DS1040
DS1060
DS1080
DS1100
DS1120
DS1140
DS1160
DS1180
DS1200
Print Line 1 characters 1 through 60
Print Line 2 characters 60 through 120
DS1220
DS1240
DS1260
Print Line 3 characters 120 through 180
Print Line 4 characters 180 through 240
Print Line 5 characters 240 through 300
DS1280
DS1300
DS1320
Print Line 6 characters 300 through 360
DS1340
DS1360
DS1380
Gui Poll
DS1400
DS1420
DS1440
DS1460
DS1480
DS1500
DS1520
DS1540
DS1560
DS1580
DS1600
DS1620
DS1640
DS1660
DS1680
DS1700
DS1720
DS1740
DS1760
DS1780
DS1800
DS1820
DS1840
DS1860
DS1880
DS1900
DS1920
Print Line 7 characters 360 through 420
Print Line 8 characters 420 through 480
Print Line 9 characters 480 through 540
DS1940
DS1960
DS1980
Print Line 10 characters 540 through 600
Print Line 11 characters 600 through 660
Print Line 12 characters 660 through 720
DS2000
DS2020
DS2040
Gui Poll
DS2060
DS2080
DS2100
Print Line 13 characters 720 through 780
Print Line 14 characters 780 through 840
DS2120
DS2140
DS2160
DS2180
DS2200
DS2220
Print Line 15 characters 840 through 900
Print Line 16 characters 900 through 960
Print Line 17 characters 960 through 1020
DS2240
DS2260
DS2280
Print Line 18 characters 1020 through 1080
DS2300
DS2320
DS2340
Gui Poll
DS2360
DS2380
DS2400
Print Line 19 characters 1080 through 1140
Print Line 20 characters 1140 through 1200
DS2420
DS2440
DS2460
Print Line 21 characters 1200 through 1260
DS2480
DS2500
Print Line 22 characters 1260 through 1320
Print Line 23 characters 1320 through 1380
Print Line 24 characters 1380 through 1440
Gui Poll
Print Line 25 characters 1440 through 1500
Print Line 26 characters 1500 through 1560
Print Line 27 characters 1560 through 1620
Print Line 28 characters 1620 through 1680
Print Line 29 characters 1680 through 1740
Print Line 30 characters 1740 through 1800
Gui Poll
Print Line 31 characters 1800 through 1860
Print Line 32 characters 1860 through 1920
Print Line 33 characters 1920 through 1980
Print Line 34 characters 1980 through 2040
Print Line 35 characters 2040 through 2100
Print Line 36 characters 2100 through 2160
Gui Poll
Print Line 37 characters 2160 through 2220
Print Line 38 characters 2220 through 2280
Print Line 39 characters 2280 through 2340
Print Line 40 characters 2340 through 2400
Print Line 41 characters 2400 through 2460
Print Line 42 characters 2460 through 2520
Gui Poll
Print Line 43 characters 2520 through 2580
Print Line 44 characters 2580 through 2640
Print Line 45 characters 2640 through 2700
Print Line 46 characters 2700 through 2760
Print Line 47 characters 2760 through 2820
Print Line 48 characters 2820 through 2880
Gui Poll
Print Line 49 characters 2880 through 2940
Print Line 50 characters 2940 through 3000
Print Line 51 characters 3000 through 3060
Print Line 52 characters 3060 through 3120
Print Line 53 characters 3120 through 3180
Print Line 54 characters 3180 through 3240
Gui Poll
Print Line 55 characters 3240 through 3300
Print Line 56 characters 3300 through 3360
Print Line 57 characters 3360 through 3420
Print Line 58 characters 3420 through 3480
Print Line 59 characters 3480 through 3540
Print Line 60 characters 3540 through 3600
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll
Gui Poll... repeated til end
Process finished with exit code 0
This post was edited by Ideophobe on Sep 23 2016 08:21am