File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes lock -1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "lock -1" Watch "lock -1" New topic
Author

lock -1

Reshma Das
Ranch Hand

Joined: Jan 29, 2002
Posts: 125
did someone implemented lock(-1)? i think this is useful for local client. but iam confused with its implementation. can someone help me?
my logic:
client :
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Actually it would probably be more useful in Remote mode. Because the only time it is called that way is when the server is being shutdown, and you want to close the database, but you don't want any clients to have a lock, and therefore corrupt the database when you close the database.
In Local mode isn't any need for locking of any kind.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Reshma Das
Ranch Hand

Joined: Jan 29, 2002
Posts: 125
server shut down by pressing ctrlC. how can u issue -1 lock at that time?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Isn't there a finalize method? like the one in Object.
Or maybe there is another way. I had a GUI for my server, so shutdown was the press of a button.
Mark
Nicky Moelholm
Ranch Hand

Joined: Jan 20, 2002
Posts: 43
Hi,
I believe you shouldn't rely on the finalize method. At least thats what the spec says. Using a shutdown hook would also be possible, but again, it should be implemented with very few statements and probably wouldn't be appropriate, if your server takes a long time to shut down.
I would advise you to do like Mark says, add a gentle form for shutdown mechanism. You can do that either in a GUI (server) component or simply add a primitive prompt, in which users can enter "stop" or "exit".


Nicky Moelholm
MyCerts: SCJP 1.2, SCJP 1.5, SCJD, SCWCD 1.3, SCBCD 1.3, SCDJWS 1.4, SCEA, IBM 253
MyBooks: IBM WebSphere Application Server V7.0 Web Services Guide
Reshma Das
Ranch Hand

Joined: Jan 29, 2002
Posts: 125
If iam going to give a gui for server shutdown it will be total of 4 windows -
server - 1 dos prompt , 1 gui
client - 1 dos prompt , 1 gui.
thats why i didnt give gui for server. if i have to give gui, can i use Activation API and reduce the dos prompt. otherwise so many windows has to be kept open. i dont like that.
why do u guys think abt it ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: lock -1
 
Similar Threads
B&S double locking
Deadlock on the thin cleint
What exactly constitutes "Booking Time"?
Locking the whole database
design for lock -1