package com.greenorange.promotion.timeout;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.CompletableFuture;

@Service
public class MyService {

    @Async
    public CompletableFuture<String> longRunningTask() {
        try {
            // 模拟长时间的操作，比如数据库查询、调用外部接口等
            Thread.sleep(1000); // 1秒
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return CompletableFuture.completedFuture("Task Completed");
    }
}
