I need to perform some medium load on shutdown but in AWS the machine is giving only 2 or less seconds to the thread to perform and only 45-47% of load is consume.
Is there is a way to increase this? or is nothing i can do!
Thread started.
07:22:09.476 [Thread-61] INFO com.company.main.Main.lambda$run$0(307) - Shutdown process start with thread: [Thread-61]
And the last line.
07:22:11.026 [Thread-61] DEBUG c.p.w.company.lambda$sort$1(341)
As you can see like 1.5 seconds is giving to thread to finish and i need to do finish the method :(
We are using EC2!
Sorry if the question is plain but this is giving me nightmares.
The code is not mine but is something like this.
public class Main extends Thread {
In public static method we create some Threads.
for (int i = 0; i < threads; i++) {
Main main = (Main) ctx.getBean("beanName");
main.setName("main-" + i);
main.start();
}
The Main class run method override
@Override
public void run() {
if (StringUtils.equals("main-0", Thread.currentThread().getName())) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
doWork();
}));
}
As you can see we are creating the shutdown on the 1 Main thread created, i did created the shutdown on the main thread as well but the same thing happens.