Answer:
monitor fileSharer
{
enum {THINKING, WAITING, READING} state[N];
condition self[N];
int total;
void open(int i) {
state[i] = WAITING;
if (i + total >= N)
{ self[i].wait(); } // Leaves monitor
state[i] = READING;
total += i;
}
void close(int i) {
state[i] = THINKING;
total -= i;
// Can signal one waiting proc whose ID won't break bank.
for (int x = N - total - 1; x >= 0; x--) {
if (state[x] == WAITING) {
self[x].signal(); break;
}
}
}
initialization.code() {
for (int i = 0; i < N; i++) {
state[i] = THINKING;
}
total = 0;
}
}
Answer:
The method to this question can be defined as follows:
Scanner in = new Scanner(. . .);
in.useDelimiter("");
Explanation:
Following are the code to the question:
import java.util.*; //import package for user input
public class Main //defining class Main
{
public static void main(String ax[])//defining the main method
{
Scanner in = new Scanner("Database");//crearing Scanner class object that pass value in its parameter
in.useDelimiter(""); //using useDelimiter
System.out.println(in.next()); //use print method to print single character value
}
}
Output:
D
Code explanation:
- In the above code inside the main method scanner class object "in" is created that pass value "Database" in its parameter.
- In the next step, useDelimiter is used that uses the scanner class object and single space n its parameter.
- In the last print, the method is used that prints object value.
Answer:
They allow for a more organized workspace. Specially in larger projects, having properly named layers helps keep things organized an sane.
Explanation: