• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multi-Threading in Java

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to use Threads in Java?
I Have to create a students account which has a method createAccount(fname,lname,email,phno,userID,Passwd,educationalInst), student reserves a book from the library using another method reserveBooks(userID,Passwd,Title,Author) and get a results for those students who didn't return books along with the due amount $1/day which has a methods getNonReturners(AdminUser,AdminPasswd,EducationalInst,NumofBooks) and setDuration(username,Bookname,NumofDays). Please, help me out how to use threads using these methods. can anyone help me out by writing a code. Its urgent for me to complete my assignment. This would be helpful. Thanks..!!
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Based on just the names of those methods (which is all you gave us), I don't see any reason to use more than one thread to implement any of them.

On the other hand if you showed us your proposed non-threaded implementations, I'm sure that people could suggest ways to use multiple threads instead of what you proposed.
 
Rao.K Reddy
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Distributed Reservation Management System (DRMS) using Java RMI
In the assignments and project, you are going to implement a simple Distributed
Reservation Management System (DRMS) for libraries: a distributed system to manage a
group of library systems used by students and administrators to help them manage book
reservations. So you will need to implement both the student interface support and admin
interface support. That is, you need to implement the functionalities that will help the end
users (students and admin, in this case) make use of the reservation system to reserve
books available within the library systems.
Consider a group of libraries each associated with a unique educational institution. The
server for each library must maintain a collection of books. Each book object can be stored
in any container of your choice, but make sure the container gives the best efficiency for
the operations related to accessing the book object. The book structure should contain the
following fields:
• Name of the book
• Author of the book
• Number of copies available
Students who need to borrow a book from the library must have an account with the server
that supports the library. An account contains the following specific information about the
student:
• First Name
• Last Name
• Email Address
• Phone Number
• Unique Username (min 6 characters and max 15 characters)
• Password of at least 6 characters
• Reserved books and duration to return the books
• Fines accumulated
• Educational Institution
The accounts are placed in several lists that are stored in a hash table according to the first
character of the username indicated in the account. For example, all the accounts with the
username starting with an “A” will belong to the same list and will be stored in a hash
table (acting as the database) using the key “A”. Each server also maintains a log containing the history of all the operations that have been performed on that server. This
should be an external text file (one per server) and shall provide as much information as
possible about what operations are performed, at what time and who performed the
operation.
The system has two distinct types of users: Students and Administrators. Students can be
identified by their username, password and educational institution. Whenever a student
performs an operation, the system must identify the library that the student belongs to
based on his/her educational institution and thus direct all the operations to that specific
server. The students maintain a file (text file) of the actions they performed on the system
and the response from the system when available. For example, if you have 10 students
using your system, you should have a folder containing 10 files. Administrators can be
identified by their username, password and educational institution. For the sake of this
assignment all the administrators have the same username which is “Admin” and the
password is also “Admin”. The administrators also maintain a file.
The operations that can be performed are the following:
Operations performed by Students
• createAccount (FirstName, LastName, EmailAddress, PhoneNumber, Username,
Password, EducationalInstitution)
When a student invokes this method through a client program called StudentClient,
the server associated with the educational institution attempts to create an account
with the information passed if the username does not exist and that the passed
information is valid according to the problem description by inserting the account at
the appropriate location in the hash table. The server returns information to the
student whether the operation was successful or not and the student file is created
and updated on the server. For simplicity it is assumed that the student has access
to creating an account in the library only if he/she is enrolled in the educational
institution.
• reserveBook (Username, Password, BookName, AuthorName)
When a student invokes this method through the client program called the
StudentClient, the server associated with this student attempts to find if the book
exist (although the book entry is found, quantity should be greater than 0 to
successfully reserve). If it does, then the corresponding quantity is decremented
and the book is updated to the reserved book list of the student. Note that the
student has to provide valid credentials to reserve a book. The duration is set to 14
days by default. Student file is updated.
Operation performed by Administrators
• getNonRetuners (AdminUsername, AdminPassword, EducationalInstitution,NumDays)
When Admin runs the getNonReturners () though the client program AdminClient,
it lists all the students’ First Name, Last Name and Phone Number who have not
returned the books with “NumDays” past their loan date in all the three educational
institutions. The admin File is updated with this information. The admin can then pass that information to the customer care agent to place a call to all the customers
to remind them about the book loan.
For the sake of this assignment, you have to make sure the getNonReturners () functions
returns
Educational Institution 1 : FirstName1 LastName1 514xxxxxxx
FirstName2 LastName2 514xxxxxxx
FirstName3 LastName3 514xxxxxxx
……..
Educational Institution 2 : FirstName1 LastName1 514xxxxxxx
FirstName2 LastName2 514xxxxxxx
FirstName3 LastName3 514xxxxxxx
……..
Educational Institution 3 : FirstName1 LastName1 514xxxxxxx
FirstName2 LastName2 514xxxxxxx
FirstName3 LastName3 514xxxxxxx
……..
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you just posted your assignment instead of doing anything yourself. Please read DoYourOwnHomework and NotACodeMill to read about the forum's attitude to that sort of behaviour.

Additionally I don't see anything about threads in that post, so I don't understand why you're asking about threads. (I just scanned for the word "thread"; the assignment might have used some other word instead, but since it was just a huge blob of text I didn't spend much time reading it in detail.)
 
Rao.K Reddy
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried to do it but i don't know how to implement using threads. My tutor told me to use multithreading in my assignment. I posted my assignment details inorder to understand my assignment, how am i supposed to do it using threads? I am sorry if i did anything wrong!
 
Rao.K Reddy
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created a class as below with getters and setters. I dont understand the logic to implement in input parameters into Hashmaps using keyboard Scanner as an input the parameters... can you help me with that? I have no idea how to do it!!!
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I notice you're supposed to use RMI to implement that assignment. Perhaps that's what your instructor meant by "threads". However I find the RMI requirement surprising because your skill level doesn't seem to be anywhere near what you'd need to understand RMI properly. So I'd suggest you talk to your instructor and find out what can be done about that gap; you aren't going to be able to get suitable help from a forum, in my opinion.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I concur with Paul's assessment. The code you posted is not going to work and it reveals gaps in your basic understanding of object-oriented programming concepts that you should try to fill before taking on the more advanced subjects of RMI and multi-threading.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic