blocked-threads

Cancel blocking AcceptTcpClient call

筅森魡賤 提交于 2019-12-28 13:46:32
问题 As everyone may already know, the simplest way to accept incoming TCP connections in C# is by looping over TcpListener.AcceptTcpClient(). Additionally this way will block code execution until a connection is obtained. This is extremely limiting to a GUI, so I want to listen for connections in either a seperate thread or task. I have been told, that threads have several disadvantages, however nobody explained me what these are. So instead of using threads, I used tasks. This works great,

How does I/O-methods like read() put a Thread in blocked state in java?

梦想的初衷 提交于 2019-12-22 08:28:18
问题 So, if i have understood this correctly, a thread goes into waiting state when we call wait on an object and it goes into blocked state when it is waiting for a lock on an object(like when trying to get into a synchronized block or method). How does I/O-methods like read() put a Thread in a blocked state though? I understand WHY it has to be in a blocked state, waiting for data that it can read but i'm also interested in HOW. How does the JVM notify the thread that it can continue when data

How does I/O-methods like read() put a Thread in blocked state in java?

北城以北 提交于 2019-12-05 11:57:08
So, if i have understood this correctly, a thread goes into waiting state when we call wait on an object and it goes into blocked state when it is waiting for a lock on an object(like when trying to get into a synchronized block or method). How does I/O-methods like read() put a Thread in a blocked state though? I understand WHY it has to be in a blocked state, waiting for data that it can read but i'm also interested in HOW. How does the JVM notify the thread that it can continue when data in the resource its trying to read, is available again? It doesn't change the state of the thread to

Cancel blocking AcceptTcpClient call

假装没事ソ 提交于 2019-11-28 09:11:12
As everyone may already know, the simplest way to accept incoming TCP connections in C# is by looping over TcpListener.AcceptTcpClient(). Additionally this way will block code execution until a connection is obtained. This is extremely limiting to a GUI, so I want to listen for connections in either a seperate thread or task. I have been told, that threads have several disadvantages, however nobody explained me what these are. So instead of using threads, I used tasks. This works great, however since the AcceptTcpClient method is blocking execution, I can't find any way of handling a task