Event objects VS Global variables
-
Hi Everyone, I am new to multithreading. I was trying controlling threads using EVENT Objects. FYI i have single process and multiple threads. I could achieve the same results without using events. Instead i used global flags to achieve the same.I can totally understand that using global variable is not a good practice. Can anybody tell, what else is a major difference and if anybody can give some specific examples where only events can be used. Thanks in advance
-
Hi Everyone, I am new to multithreading. I was trying controlling threads using EVENT Objects. FYI i have single process and multiple threads. I could achieve the same results without using events. Instead i used global flags to achieve the same.I can totally understand that using global variable is not a good practice. Can anybody tell, what else is a major difference and if anybody can give some specific examples where only events can be used. Thanks in advance
The main difference is that a thread can wait on an event but not a global variable.
The difficult we do right away... ...the impossible takes slightly longer.
-
Hi Everyone, I am new to multithreading. I was trying controlling threads using EVENT Objects. FYI i have single process and multiple threads. I could achieve the same results without using events. Instead i used global flags to achieve the same.I can totally understand that using global variable is not a good practice. Can anybody tell, what else is a major difference and if anybody can give some specific examples where only events can be used. Thanks in advance
When a thread waits on an event it isn't scheduled and so consumes so no CPU time. Waiting on a global variable requires polling and so does.
Steve
-
When a thread waits on an event it isn't scheduled and so consumes so no CPU time. Waiting on a global variable requires polling and so does.
Steve
Stephen Hewitt wrote:
...and so consumes so CPU time. Waiting on a global variable requires polling and so does.
Am I misreading this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Stephen Hewitt wrote:
...and so consumes so CPU time. Waiting on a global variable requires polling and so does.
Am I misreading this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
He meant "NO cpu time."
The difficult we do right away... ...the impossible takes slightly longer.
-
Stephen Hewitt wrote:
...and so consumes so CPU time. Waiting on a global variable requires polling and so does.
Am I misreading this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
You are reading correctly, I just spelt "no" wrong. And it's an easy word too.
Steve
-
Hi Everyone, I am new to multithreading. I was trying controlling threads using EVENT Objects. FYI i have single process and multiple threads. I could achieve the same results without using events. Instead i used global flags to achieve the same.I can totally understand that using global variable is not a good practice. Can anybody tell, what else is a major difference and if anybody can give some specific examples where only events can be used. Thanks in advance