开发者

Message "current thread is in sleep,wait or join state" - locking?

开发者 https://www.devze.com 2022-12-11 08:00 出处:网络
I have encountered (for me) very strange problem. In my app, when pressing start button, all threads are activated, when pressing stop button, all threads are aborted and all collections are cleared.

I have encountered (for me) very strange problem. In my app, when pressing start button, all threads are activated, when pressing stop button, all threads are aborted and all collections are cleared. This is all happen at the main thread, while other procceses have their own threads or are running via threadpool. However, today I replaced ReaderWriterLock with 开发者_如何学JAVAReaderWriterLockSlim and rarely, when I press "STOP" button the app will freeze. With Break all I can see the coed is stuck on the line this.someobject.TryEnterWriteLock(-1) and when I display details, the variables are all filled with this message:

"Cannot .... because current thread is in sleep,wait or join state"

I dont understand it - its the main application thread. I do not expect direct answer rather than advice what should I look for, this message I have never seen before. Thank you!


Do not be confused by the message - it is there because the debugger cannot access the values - your main thread is locked. Why it is locked - there is no saying without the code.

BTW did you try to look at other threads in your app?

0

精彩评论

暂无评论...
验证码 换一张
取 消