What type of application are you building? For web applications Shiro can handle the Login (collecting of the username/password) and the thread binding for you, so you don't actually need to do that. (this all happens with the ShiroFilter, and associated chain)
That said, if you do not want to use shiro-web, you could accomplish the same thing by sticking your code in a Runnable: https://github.com/apache/shiro/blob/b0091dfef63288f957389bce42f5a8e85329a1aa/web/src/main/java/org/apache/shiro/web/servlet/AbstractShiroFilter.java#L359-L368 Take a look at the Subject / Thread Association doc: https://shiro.apache.org/subject.html#thread-association On Fri, Nov 20, 2020 at 8:50 AM Alex Orlov <ooo_satu...@mail.ru> wrote: > Hi all, > > I use the following code: > var subject = SecurityUtils.getSubject(); > subject.login(new SomeToken()); > > As I understand, after `subject.login(new SomeToken())` if subject > successfully logs in, he > is bound to the current thread. Could anyone say how I can clear current > thread, without subject.logout()? > I just want the subject leaves in system until it is necessary again (for > example until next request). > > I’ve read this article https://shiro.apache.org/subject.html but didn’t > find answer there. Please, help. > > -- > Best regards, Alex Orlov >