Storybook - Open Source Novel Writing Software
- Before adding a new feature request please check if an identical task already exists.
- Describe your new feature request as short and precise as possible. Use the possibility of attaching a screen shot or sketch.
- Text can be formatted using the Dokuwiki Syntax.
FS#19 - Multiple Storybook instances
Attached to Project:
Storybook
Opened by Intertec (Intertec) - Wednesday, 09 November 2011, 13:40 GMT+2
Last edited by Intertec (Intertec) - Thursday, 26 April 2012, 14:26 GMT+2
Opened by Intertec (Intertec) - Wednesday, 09 November 2011, 13:40 GMT+2
Last edited by Intertec (Intertec) - Thursday, 26 April 2012, 14:26 GMT+2
|
Details
Single Application Instanceprivate static boolean lockInstance(final String lockFile) { try { final File file = new File(lockFile); final RandomAccessFile randomAccessFile = new RandomAccessFile( file, "rw"); final FileLock fileLock = randomAccessFile.getChannel().tryLock(); if (fileLock != null) { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { fileLock.release(); randomAccessFile.close(); file.delete(); } catch (Exception e) { System.err.println("Unable to remove lock file: " + lockFile); e.printStackTrace(); } } }); return true; } } catch (Exception e) { System.err .println("Unable to create and/or lock file: " + lockFile); e.printStackTrace(); } return false; } |
This task depends upon