Q:

Start a schedule when current running schedule hasn't finished yet Cron4j

I'm using Cron4j to create backup schedules for a database. Assume that we had 2 schedules, the first started at 5.00 pm, and the second started at 5.30 pm, both at the same day. I don't know what would happend if the backup time of the first schedule was greater than 30 minutes. I assume that the second schedule would still start and could ruin the database as the first one wasn't finished and the database wasn't updated. What should i do in that case?

A:

You can create thread with custom name and put you bacup process into.
And the next time you try find him by name. 
If he will be finded - gackup is working.
    Set<Thread> threads = Thread.getAllStackTraces().keySet();
    boolean isWorking = threads.stream().anyMatch(t -> t.getName().equals("My backup is working"));

    if (!isWorking) {
        Runnable task = () -> {
            Thread.currentThread().setName("My backup is working");
            //some code of run backup
            System.out.println("start backup");
        };

        Thread thread = new Thread(task);
        System.out.println("Done!");
        thread.start();
    }

