jay's old blog

this blog will be deleted soon - please visit my new blog - https://thesanguinetechtrainer.com

Thread Parameters and Shared variables

Threads, as with most things, can take parameters. Just as you can start a thread, you can stop as well. We will talk about thread stopping here as well.  

Thread parameters are just like a method parameters. You send values and make the most of it. You already know about arguments and parameters. This is similar, but works with threads. First thing to remember is that the thread takes only 'object' type parameter. After receiving the object, it is up to you to cast it properly and use it accordingly.  

It is possible to use a shared variable to make the threads resuming or not. A shared variable is useful when you want to branch out of threads, stop them or executing them depending on what the shared variable dictates.  

As always, associated code has the above illustration. With comments and everything. 

Comments are closed