91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

實驗一:生產者消費者[C#][test1] 實驗二:處理機調度[C#][test2][時間片輪轉法] 實驗三:存儲管理[C#][test3-1][test3-2][分頁存儲、缺頁中斷] 實驗四:文件系統[C#][test4]

資源截圖

代碼片段和文件信息

using?System;
using?System.Threading;

public?class?Synchronized
{
????private?string[]?buffer?=?{?““?““?““?};
????private?int?bufferCount?=?0;
????private?int?readLocation?=?0?writeLocation?=?0;

????public?Synchronized()
????{
????}

????public?string?getBuffer()
????{
????????lock?(this)
????????{
????????????Thread.Sleep(300);
????????????while(bufferCount?==?0)
????????????{
????????????????Console.WriteLine(“數據為空,無法讀取“);
????????????????Monitor.Wait(this);
????????????}
????????????string?readValue?=?buffer[readLocation];
????????????bufferCount--;
????????????readLocation=(readLocation+1)%buffer.Length;
????????????Monitor.PulseAll(this);
????????????return?readValue;
????????}
????}
????public?void?setBuffer(string?writeValue)
????{
????????lock?(this)
????????{
????????????Thread.Sleep(300);
????????????while?(bufferCount?==?buffer.Length)
????????????{
????????????????Console.WriteLine(“緩沖區滿,無法寫入“);
????????????????Monitor.Wait(this);
????????????}
????????????buffer[writeLocation]?=?writeValue;
????????????bufferCount++;
????????????writeLocation?=?(writeLocation?+?1)?%?buffer.Length;
????????????Monitor.PulseAll(this);
????????}
????}
}

public?class?Producer
{
????Synchronized?shared;
????public?Producer(Synchronized?sharedLocation)
????{
????????shared?=?sharedLocation;
????}
????public?void?produce(){
????????string?name?=?Thread.CurrentThread.Name;
????????string?tag?=?“(No.“?+?name[name.Length?-?1]+“)“;
????????for?(int?count?=?1;?count?<=?100;?count++)
????????{
????????????shared.setBuffer(tag+“.“+count);
????????????Console.WriteLine(name?+?“?生產:“?+?tag?+?“.“?+?count);
????????}
????????
????????Console.WriteLine(name?+?“done?prodcuing.“);
????}
}

public?class?Consumer
{
????private?string?value;
????Synchronized?shared;
????public?Consumer(Synchronized?sharedLocation)
????{
????????shared?=?sharedLocation;
????}
????public?void?consome()
????{
????????string?name?=?Thread.CurrentThread.Name;
????????for?(int?count?=?1;?count?<=100;?count++)
????????{
????????????value?=?shared.getBuffer();
????????????Console.WriteLine(name?+?“?消費:“?+?value);
????????}
????????
????????Console.WriteLine(name+“done?consuming.“);
????}
}

public?class?ThreadTest
{
????public?static?void?Main()
????{
????????Synchronized?shared?=?new?Synchronized();
????????Producer?producer1?=?new?Producer(shared);
????????Consumer?consumer1?=?new?Consumer(shared);
????????Thread?producerThread?=?new?Thread(new?ThreadStart(producer1.produce));
????????producerThread.Name?=?“生產者1“;
????????Thread?producerThread2?=?new?Thread(new?ThreadStart(producer1.produce));
????????producerThread2.Name?=?“生產者2“;
????????Thread?producerThread3?=?new?Thread(new?ThreadStart(producer1.produce));
????????producerThread3.Name?=?“生產者3“;
????????Thread?producerThread4?=?new?Thread(new?ThreadStart(producer1.produce));
????????producerThread4.Name?=?“生產者4“;
????????Thread?consum

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????3549??2018-06-01?20:14??test1.cs
?????文件????????3451??2018-06-01?20:12??test2.cs
?????文件????????3786??2018-06-01?20:12??test3-1.cs
?????文件????????4754??2018-06-01?20:11??test3-2.cs
?????文件???????16105??2018-06-01?20:13??test4.cs

評論

共有 條評論