freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

畢業(yè)設(shè)計(jì)java多線程同步機(jī)制及其應(yīng)用(完整版)

  

【正文】 WE 方向綠燈時(shí)間 int Time 臨時(shí)時(shí)間變量 String s 顯示紅綠燈標(biāo)簽 boolean FlagRed true 是否是紅燈的標(biāo)志 boolean Pos true boolean BE true Color ReColor Colorred 紅色 Color GrColor Colreen 綠色 Color YeColor Coloryellow 黃色 Color WhColor Colray 灰白色 Color NowWEColorY 現(xiàn)在黃燈位置的顏色 Color NowWEColorR 現(xiàn)在紅燈位置的顏色 Color NowWEColorG 現(xiàn)在綠燈位置的顏色 TextField TimeWE new TextField 1 public TrafficLightThread Color What boolean WEPos 初始化顏色位置 if WEPos false 如果不是 WE 方向 s 南北方向 else s 東西方向 Pos WEPos NowWEColorR WhColor NowWEColorG WhColor NowWEColorY WhColor setSize 300 300 初始化畫(huà)板大小 setBackground Colorblack 初始化背景色 if What ReColor 判斷初始化時(shí)的顏色 NowWEColorR ReColor else NowWEColorG GrColor public void paint Graphics g 重載 canvas 的繪圖方法 gsetColor Colorwhite if FlagRed 如果現(xiàn)在紅燈亮起顯示紅燈時(shí)間 gsetColor ReColor gdrawString s 紅燈剩余時(shí)間 IntegertoString Time 50 50 else 如果現(xiàn)在紅燈不亮則顯示綠燈時(shí)間 gsetColor GrColor gdrawString s 綠燈剩余時(shí)間 IntegertoString Time 50 50 gsetColor Colray 設(shè)置顏色為灰白色 gfillRect 0 150 300 30 畫(huà)矩形框 gfillRect 30 0 30 300 gfillRect 270 0 30 300 gsetColor NowWEColorG gfillOval 2 98 50 50 畫(huà)綠燈 gsetColor NowWEColorY gfillOval 54 98 50 50 畫(huà)黃燈 gsetColor NowWEColorR gfillOval 106 98 50 50 畫(huà)紅燈 public void Changed 燈色變換方法 NowWEColorY WhColor 熄黃燈 if NowWEColorG GrColor 如果綠燈亮起 NowWEColorG WhColor 熄綠燈 NowWEColorR ReColor 亮紅 燈 else NowWEColorR WhColor 否則熄紅燈 NowWEColorG GrColor 亮綠燈 public void run 線程的運(yùn)行方法 try if Pos false 如果不是 WE 方向則交換紅綠燈時(shí)間 Time TimeWER TimeWER TimeWEG TimeWEG Time while BE if NowWEColorR ReColor 紅燈是否亮起 FlagRed true 是則紅燈亮起標(biāo)記為真 else FlagRed false 否則為假 if FlagRed 如果是紅燈亮起 Time TimeWER 現(xiàn)在顯示時(shí)間為紅燈持續(xù)時(shí)間 while Time 1 當(dāng)時(shí)間大于 0 秒時(shí) Time 時(shí)間數(shù)減 1 秒 repaint Threadsleep 1000 暫停 1 秒 end While Changed 紅綠燈變換 repaint 刷新顯示 else 如果是綠燈亮起 Time TimeWEG 現(xiàn)在顯示時(shí)間為綠燈持續(xù)時(shí)間 while Time 1 當(dāng)時(shí)間大于 0 秒時(shí) Time 時(shí)間數(shù)減 1 秒 if Time 7 當(dāng)時(shí)間小于 5 秒時(shí) if FlagRed false 檢查紅燈是否亮起 if Time 2 1 當(dāng)綠燈亮起并且現(xiàn)在時(shí)間為奇數(shù)時(shí) NowWEColorG GrColor 綠燈亮 else NowWEColorG WhColor 現(xiàn)在時(shí)間為偶數(shù)時(shí)綠燈熄滅 if Time 2 當(dāng)時(shí)間等于 1 秒時(shí)黃燈開(kāi)始亮起 NowWEColorG WhColor NowWEColorY YeColor endIF endIF repaint Threadsleep 1000 暫停 1 秒 endWhile Changed 紅綠燈變換 repaint 刷新顯示 endIF endWhile catch Exception x Sytln x public static void main String[] args 主方法 new CarMonitor run import javaawt import t class CarMonitor extends Frame implements Runnable 繼承 Frame 的 CarMonitor int SleepTime 10000 默認(rèn)監(jiān)視器周期 10 秒 Button b1 new Button 修改 定義按鈕 Button b2 new Button 東西車流量較大 Button b3 new Button 南北車流量較大 Button b4 new Button 確定 Label L1 new Label 東西方向紅燈時(shí)間 秒 定義文本標(biāo)簽 Label L2 new Label 東西方向綠燈時(shí)間 秒 Label L3 new Label 設(shè)置監(jiān)視器周期 秒 TextField tf1 new TextField 1 定義文本域 TextField tf2 new TextField 1 TextField tf3 new TextField 1 TextArea Info new TextArea 交通燈信息 3 55ScrollbarVERTICAL boolean a false final Monitor M1 new Monitor 南北方向 final Monitor M2 new Monitor 東西方向 final TrafficLightThread T1 new TrafficLightThread Colorred true final TrafficLightThread T2 new TrafficLightThread Colreen false final Thread R1 new Thread T1 東西方向交通燈線程 final Thread R2 new Thread T2 南北方向交通燈線程 public CarMonitor CarMonitor 構(gòu)造方法 setSize 610 418 設(shè)置容器大小 setLayout new FlowLayout FlowLayoutCENTER 0 0 設(shè)置容器布局 addWindowListener new WindowAdapter 窗口關(guān)閉事件 public void windowClosing WindowEvent x Systemexit 0 add T1 開(kāi)始初始化容器 add T2 add L1 add tf1 add L2 add tf2 add b1 add b2 add b3 add L3 add tf3 add b4
點(diǎn)擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1