Questions tagged [thread-state]

Thread state describes state of thread in given time.

Thread can have one of states at the time.

States are implementation/platform dependent, but basically all of this states are implemented on most platforms:

  • NEW A Fresh thread that has not yet started to execute.

  • RUNNABLE A thread that is executing in the Java virtual machine.

  • BLOCKED A thread that is blocked waiting for a monitor lock.

  • WAITING A thread that is wating to be notified by another thread.

  • TIMED_WAITING A thread that is wating to be notified by another thread for a specific amount of time.

  • TERMINATED A thread whos run method has ended.

39 questions
47
votes
8 answers

How to check if Thread finished execution

I have following problem: I want to check (C#) if a thread has finished execution, i.e. if the thread method has returned. What I do now is call Thread.Join(1), but this gives a 1 ms delay. Is there any way to simply check if a thread has finished.…
Bogi
  • 2,274
  • 5
  • 26
  • 34
35
votes
4 answers

Java thread state transition, WAITING to BLOCKED, or RUNNABLE?

There seems to be a discrepancy between SO consensus and nearly every Java thread state diagram on the Internet; specifically, regarding thread state transition from WAITING after notify() or notifyAll() is invoked... WAITING never goes directly to…
raffian
  • 31,267
  • 26
  • 103
  • 174
16
votes
2 answers

Thread lifecycle in .NET framework

The state of a thread in .NET framework is explained in this link. I recently saw this picture in a web-site and a couple of questions came to my mind: The thread lifecycle in the OS is not completely aligned with thread lifecycle in .NET…
ManiAm
  • 1,759
  • 5
  • 24
  • 43
14
votes
1 answer

Thread.IsAlive and Thread.ThreadState==ThreadState.Running

I am using to check the condition of a thread with if(Thread.IsAlive). A form is running in this thread. At times during execution, even though the form remains open, the call to Thread.IsAlive seems to be evaluating to false. I thought to perform…
Victor Mukherjee
  • 10,487
  • 16
  • 54
  • 97
10
votes
4 answers

async await: is the main thread suspended?

I was reading about async/await keywords and I've read that: When the flow of logic reaches the await token, the calling thread is suspended until the call completes. Well, I've created a simple windows forms application, placed two labels, a…
Buda Gavril
  • 21,409
  • 40
  • 127
  • 196
7
votes
2 answers

difference between Thread state blocked and waiting

I have read the answer through the following posting: Difference between WAIT and BLOCKED thread states However, I am still puzzled. I want to know what is the difference on the JVM level and what is the difference on the CPU level. Whether both of…
Timi
  • 892
  • 1
  • 8
  • 17
7
votes
1 answer

java threadump significance of "waiting on condition"

I have a threaddump of an app which showed 3 threads like below. =============== "http-443-11" daemon prio=10 tid=0x00000000473bc800 nid=0x3590 waiting on condition [0x0000000061818000] java.lang.Thread.State: WAITING (parking) at…
anjanb
  • 12,999
  • 18
  • 77
  • 106
6
votes
2 answers

How can I get the state of a program?

I'm observing an program and want to kill it, if it is for some time in the state "wait:executive". Here is a screenshot of the Process Explorer: How can I get that state by code? Or could maybe tell me somebody what that state exactly mean? This…
rekire
  • 47,260
  • 30
  • 167
  • 264
6
votes
1 answer

mysql show processlist query shows state = null

I have a script running a batch of very similar queries. All of them, except one, run without any problem. Only one query is getting stuck. In "show processlist" the query has state=null According to docs, show processlist should report…
user1312090
  • 63
  • 1
  • 3
4
votes
2 answers

What does the java thread's state really mean?

I am learning the tool in Android Studio, get thread dump, as follow: I notice the different state of every thread like this, I can see there are runnable,sleeping,waiting. And I deep into the thread stack, most thread stack like this, "<61>…
kidoher
  • 2,297
  • 2
  • 12
  • 19
3
votes
4 answers

How to determine that a win32 thread is either in Wait or Join or Sleep state in c++

What I actually search for is c++/win32 equivalent for .net ThreadState Enumeration. Any suggestions?
honzajscz
  • 2,850
  • 1
  • 27
  • 29
3
votes
1 answer

Can a java project with a runnable that runs at a fixed rate stop after a while? Mine keeps freezing after about 40 hours

After learning java on my own, i began a project for getting data from a website through api calls for a game called torn. There were a few little details i fixed thanks to some help, but the main issue i had is still not solved. after a day and a…
bookish303
  • 65
  • 5
3
votes
6 answers

Multi thread worker thread status

I create my threads as for (int i = 0; i < threadCount; i++) { Searcher src = new Searcher(i, this); threads[i] = new Thread(new ThreadStart(src.getIpRange)); threads[i].Name = string.Format(i.ToString()); } foreach (Thread t…
Rapunzo
  • 966
  • 5
  • 21
  • 42
3
votes
1 answer

C# Thread's state and "Sleep"

I'm trying to get a .NET thread state. For this I check the ProcessThread.ThreadState property. However when I use Thread.Sleep on that thread and check its state with Process Explorer - I see that it's in "Wait: Delay Exectuion", while my…
Idov
  • 5,006
  • 17
  • 69
  • 106
3
votes
0 answers

ThreadStateException c#

I have a ThreadStateException that i need to have STAThread... The problem appeared yesterday, I even ckecked previous versions from my git repo (which were 100% working) - now they're not. Code for main: [STAThread] static void Main() { …
kaczmen
  • 528
  • 4
  • 12
1
2 3