× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 11/3/2014 11:18 AM, CRPence wrote:
Currently I'm looking at using this code to make the lock.

IFSRandomAccessFile lockFile = new IFSRandomAccessFile(as400,
LOCKFILE, "rw");

IFSKey lockKey = lockFile.lock(0L, 10L);


I would think more appropriate, including the optional fourth
argument [int shareOption] for the open request, using the value of
SHARE_NONE; i.e. preventing an open by any other process\thread
irrespective that other thread properly implementing the
keyed-locking scheme.?

Assuming I understand what you are saying, I'm not especially worried about another process trying to read or lock the LOCKFILE in question. The chances of another application trying to use the same file in the IFS is vanishingly slim.

Also, I am unsure of the default for the optional fifth argument
[int existenceOption] for the open request, but possibly the value
OPEN_OR_FAIL is desirable if the semaphore is implemented as a "lock
on *a known* IFS file" [emphasis mine].?

The file in question should *NOT* exist. If it does, then reason would the application left the file behind accidentally (aborted, killed, etc, before cleanup). I've changed my code to be the following:

file = new IFSFile(as400, LOCKFILE_NAME);

lockFile = new IFSRandomAccessFile(file, "rw",
IFSRandomAccessFile.SHARE_ALL,
IFSRandomAccessFile.OPEN_OR_CREATE);

lockKey = lockFile.lock(0L, 10L);

(the above code is actually encapsulated in a class)

This way, once the lock is no longer needed, I perform the unlock and then delete the lock file.

david


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.