Question

Explain why the Transaction class method nextTxNumber is synchronized.

1) What could happen if it were not?

2) Is it a problem for the other methods in that class to not be synchronized?

Please explain your answer.public int size(String filename) { Block dummyblknew Block(filename, END_OF_FILE); concurMgr.sLock (dummyblk); return SimpleD

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 1:
It is synchronized because it is returning a sequence number so it should be unique so
that is the reason we are not allowing 2 threads to access that method at time
If we remove at some times 2 threads might execute at time both threads will get the same number

Answer 2:
It is not a problem because those methods will not cause the data inconsistency

Note : If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
Explain why the Transaction class method nextTxNumber is synchronized. 1) What could happen if it were...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ICS Quiz need help! open the Node.java file and look at the main() method driver/test method....

    ICS Quiz need help! open the Node.java file and look at the main() method driver/test method. Towards the end of the method, 5 nodes are instantiated and linked. These are what are printed out in the loop. Your task is to DRAW the structure of those 5 linked nodes using the method from the slides (list of Coins). String objects, Nodes, and pointer links must be shown. You may use software or draw on paper. Upload your drawing or a...

  • Implement a class CSVReader that reads a CSV file, and provide methods: int numbOfRows() int numberOfFields(int...

    Implement a class CSVReader that reads a CSV file, and provide methods: int numbOfRows() int numberOfFields(int row) String field(int row, int column) Please use the CSVReader and CSVReaderTester class to complete the code. I have my own CSV files and cannot copy them to here. So if possible, just use a random CSV file. CSVReader.java import java.util.ArrayList; import java.util.Scanner; import java.io.*; /**    Class to read and process the contents of a standard CSV file */ public class CSVReader {...

  • public class File_In_36 {    private String filename;    public int[][] matrix()    {       //...

    public class File_In_36 {    private String filename;    public int[][] matrix()    {       // 1. matrix will call scan_File to determine whether or not the file       // name entered by the user actually exists       // 2. matrix will call size_matrix to determine the number of integers       // in the input file and set the instance variable matrix_size to that       // number       // 3. matrix will call check_square to determine whether or not matrix_size...

  • Solve this using Java for an Intro To Java Class. Provided files: Person.java /** * Models...

    Solve this using Java for an Intro To Java Class. Provided files: Person.java /** * Models a person */ public class Person { private String name; private String gender; private int age; /** * Consructs a Person object * @param name the name of the person * @param gender the gender of the person either * m for male or f for female * @param age the age of the person */ public Person(String name, String gender, int age) {...

  • Create a class called MazeSolver: public class MazeSolver {    private char[][] maze;    private int startx,                    &

    Create a class called MazeSolver: public class MazeSolver {    private char[][] maze;    private int startx,                     starty;   Public MazeSolver(String fileName) throws IOException   {      // create an object to read information from “fileName”      // read the maze dimension (row col) from the file      // Allocate the space for maze      // initialize array maze with contents of the file      // find startx and starty      printMaze(); // a method that prints the maze      // solveMaze() is a recursive method to solve the maze      if(solveMaze(maze,startx,starty))...

  • Language Java Step 1: Design a class called Student. The Student class should contain the following...

    Language Java Step 1: Design a class called Student. The Student class should contain the following data: firstName lastName studentID totalCredits gpa Your class should implement the “sets” and “gets” for the class. Include methods: equals, compareTo, toString. Change the toString method (from class) to put each member variable on a new line. Step 2: Write a driver program to test that Student works correctly. Test is with 3 students as given in class. Step 3: Write a “registration” program...

  • what are the debuggers in Java? import java.text.NumberFormat; /** * * This class represents a circle...

    what are the debuggers in Java? import java.text.NumberFormat; /** * * This class represents a circle that would be used as part * of a larger geometry application */ public class Circle {    private double radius;    private NumberFormat numberFormat; /** *    Constructor for the Circle. * @param radius for the circle */    public Circle(double r) {        radius = r;    } /** *    This method uses the radius of the circle to compute...

  • JAVA PROBLEMS 1. Update the below method to throw an IndexOutOfBoundsException: public E get(int index) {...

    JAVA PROBLEMS 1. Update the below method to throw an IndexOutOfBoundsException: public E get(int index) {         if (index < 0 || index > numItems) {             System.out.println("Get error: Index "                         + index + " is out of bounds.");             return null;         }         return array[index]; } Hint: Update both the method signature and the method body! 2. Update the below method to include a try-catch block rather than throwing the exception to...

  • Hi I really need help with the methods for this lab for a computer science class....

    Hi I really need help with the methods for this lab for a computer science class. Thanks Main (WordTester - the application) is complete and only requires uncommenting to test the Word and Words classes as they are completed. The needed imports, class headings, method headings, and block comments are provided for the remaining classes. Javadocs are also provided for the Word and Words classes. Word The Word class represents a single word. It is immutable. You have been provided...

  • This is my playlist class: class Playlist{       private String name;    private int numberOfRecordings...

    This is my playlist class: class Playlist{       private String name;    private int numberOfRecordings = 0;    private int durationInSeconds = 0;    private int MAX_PLAYLIST_SIZE;    Recording recordingslist[];       Playlist(){        name = "Unknown";        MAX_PLAYLIST_SIZE = 5;        recordingslist = new Recording[MAX_PLAYLIST_SIZE];        durationInSeconds = 0;    }       Playlist(String name, int size){        this.name = name;        this.MAX_PLAYLIST_SIZE = size;        recordingslist = new Recording[MAX_PLAYLIST_SIZE];   ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT