singleinstance

To control running instances of one program


Introduction

The config item 'singleinstance' is to allow only one instance can be running at the same time. By default, the number of running instances are not limited.


singleinstance

The 'singleinstance' can be followed by one of 3 values:

singleinstance false|true|custom

The default value is 'false', there is no limit on how many instances running at the same time.

The value 'true' means only one instance are allowed at the same time, so the second instance of the same program will fail to start.

The value 'custom' is to enable the feature of communication between instances of the same program, then java program can control the running instances in your own way easily.


singleinstance custom[since 2.1.5]

The value 'singleinstance custom' is to enable the communcation between instances of the same program. Through the commucation API, java program can

  1. Get the first instance (pid) and current instance (pid) and all running instances (pids) and their start order. So java program can know whether this is the first instance by comparing the "first == current", and java program can know its start order by finding itself in all instances.
  2. Send a message to another instance specified by the pid, the message can be any java serializable objects.

By the help of communication API, java program can discuss between instances and decide which one exit and which one keep running, and leave some last words to the other instance before exit.


Instances

For more information about integrate with commucation API,

Add new comment