multithreading - Long running background thread causes HTTP request to timeout -
i have spring 3.0 webmvc application running on tomcat 7. on application startup kick off background thread load in-memory cache records db. thread typically takes on hour load data db. in same application have @controller annotated class exposes rest interface clients can objects loaded cache. one of our requirements rest requests made prior data load being finished return service_unavailable (503) http code client immediately. accomplish set simple check of boolean flag each request method in controller makes before doing work. if value false method should return 503 code. loader thread set flag true once completed load allow request methods function normally. the problem background thread seems causing http requests sent controller timeout after 30 seconds instead of hitting flag , returning 503 code client. i'm not expert in tomcat threading issues , wonder if i'm doing wrong when creating long running background thread? using "implements runnable" method