Why is it thread-safe after service is injected into controller in springmvc?

it is said that springmvc is thread-safe. I know that stateless objects must be thread-safe. But when Service is injected into Controller, it becomes a stateful object . Is it still thread-safe?

//
public class UserController {
    
}

//
public class UserController {

    int a;
    
}

//?????
public class UserController {

    @AutoWired
    private UserService userService;
    
}

I hope the person who knows it will solve the problem for my younger brother. Thank you!
add: I know about ThreadLocal and single-case multiple cases (scope=prototype). I just want to know the stateless and stateless situations I described above.


you don't know what thread safety means. UserService itself is not thread-safe. Do you modify userService in userController? Just call the method in userService, right? Methods are thread-safe, and multithreading calls an instance's method and copies variables in memory, so as long as you don't modify the userService instance in userConstroller.


@ Controller's default singleton pattern


the service, you inject yourself requires you to ensure thread safety. Spring can't help you do this.


the injected bean itself is singleton.

Menu