• 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

ready to upload,but...

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,Peter and other guys:
I read the instruction again,and I found my assignment are not match the requirement at two points:
In Sun instrution:

The lock method should block until the requested lock can be applied


In my assignment:
public syrnchonized lock(int recNum,Object clientId){
....
if (the record was locked by other cliend)[
wait();
}
}
When the record that you want to lock was locked by other client,you will go to the waiting pool and give up the objec lock of lock() mehtod,so other cliend can access the mehod. The lock() method was not block,would I will lost the point?

To connect with your server,you should create a client program.This implementation should include a class that implements the same pulbic methods as the Data class,although it will need different constructors to allow it to support the network configuration.


On my client side,I define a LocalModel class implements the DataAccess interface,which contains the all public methods of Data class,but this class is only used for local database,donot need different constructors to support network.For the remote object,I get a reference of remote object and invoke the remote methods through the reference,I also donot need the network configuration.
Do I need to change my design?
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


if (the record was locked by other cliend){
wait();
}
}


A much preferred way of doing it is:

Unlike your original code, this code will guarantee that you check the record before locking it.


When the record that you want to lock was locked by other client,you will go to the waiting pool and give up the objec lock of lock() mehtod,so other cliend can access the mehod. The lock() method was not block,would I will lost the point?


When your thread is in the waiting state, it IS blocked, so there is no violation of Sun's requirement.
Eugene.
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my assignment instruction:
***********************************************
The remote client code that you write must provide all the public methods of the suncertify.db.Data class.
***********************************************
It seems like SUN changed instruction.
I think you had better do it as your instruction said.
 
jianqiang huhu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys:
Thanks for your reply!

When your thread is in the waiting state, it IS blocked, so there is no violation of Sun's requirement.


yes,when my thread is in the waiting state,it is not blocked,but have ot give off the object lock of syrnchonzied block,it is different with Sun's instruction:

The lock method should block until the requested lock can be applied


Maybe it means before you lock the record,you will stay in the lock() method and other threads can not access this method,is right?
 
HiBob Chu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the block means block to run instead of blocking to be called.
[ November 26, 2002: Message edited by: HiBob Chu ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jianqiang,
in the lock method you synchornize on the collection of locks or the method. Using the while statement to check availability of the record, then issue the wait surrounded by a try, which catches the InterruptedException. This way you will stay until you can lock, then it will exit out of the while loop, and you can then add the record to you collection.
As far as the Public methods instructions, what you have is basically correct, there is some information missing that you didn't include in your post, but that doesn't really matter to say that you have two classes one for local and one for remote and both have all the public methods of Data, requirement filled.
Mark
 
jianqiang huhu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!
so I will upload my assignment,do I need to send an email to Sun before upload the assignment?
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you can try first, but I think most people find they will have to send an e-mail to get the permission to upload.
mark
 
jianqiang huhu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,Mark!
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic