⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boat.java

📁 nachos操作系统框架
💻 JAVA
字号:
package nachos.threads;import nachos.ag.BoatGrader;public class Boat{    static BoatGrader bg;        public static void selfTest()    {	BoatGrader b = new BoatGrader();		System.out.println("\n ***Testing Boats with only 2 children***");	begin(0, 2, b);//	System.out.println("\n ***Testing Boats with 2 children, 1 adult***");//  	begin(1, 2, b);//  	System.out.println("\n ***Testing Boats with 3 children, 3 adults***");//  	begin(3, 3, b);    }    public static void begin( int adults, int children, BoatGrader b )    {	// Store the externally generated autograder in a class	// variable to be accessible by children.	bg = b;	// Instantiate global variables here		// Create threads here. See section 3.4 of the Nachos for Java	// Walkthrough linked from the projects page.	Runnable r = new Runnable() {	    public void run() {                SampleItinerary();            }        };        KThread t = new KThread(r);        t.setName("Sample Boat Thread");        t.fork();    }    static void AdultItinerary()    {	/* This is where you should put your solutions. Make calls	   to the BoatGrader to show that it is synchronized. For	   example:	       bg.AdultRowToMolokai();	   indicates that an adult has rowed the boat across to Molokai	*/    }    static void ChildItinerary()    {    }    static void SampleItinerary()    {	// Please note that this isn't a valid solution (you can't fit	// all of them on the boat). Please also note that you may not	// have a single thread calculate a solution and then just play	// it back at the autograder -- you will be caught.	System.out.println("\n ***Everyone piles on the boat and goes to Molokai***");	bg.AdultRowToMolokai();	bg.ChildRideToMolokai();	bg.AdultRideToMolokai();	bg.ChildRideToMolokai();    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -