java - Can Someone Explain Threads to Me? -


I am planning to add threaded processes to my application to speed up the execution, but the problem is that I honestly do not know how to use thread, or what is considered to be "thread safe" For example, how a game engine uses threads in its rendering processes, or in which context only the thread is a Hurdle will not be considered ? Can someone tell me some resources or help explain something here?

This is a very broad topic but these are the things I would like to know that I do not know anything about thread It was:

  • They are the units of execution in the same process that are in parallel - what does that mean that the current unit of execution in the processor swiftly switches in different ways Can be obtained. Switching is called " context switching ", and some overheads are connected to it.

  • They can share the memory! This is where the problems can occur. I talk about it later in the bullet point in depth.

  • The advantage of parallelizing your application is that the logic machine that uses different parts of the machine can be simultaneously. That is, if the part of your process is I / O-bound and its part is CPU-bound, then I / O intensive operation does not have to wait until the CPU-intensive operation. Some languages ​​allow you to run threads at the same time if you have a multicore processor (and thus parallel with CPU-intensive operations), although this is not always the case.

  • Thread-safe means that there is no state of the race , which depends on the execution time of your process (whatever Do not want to trust you) is the word used for problems occurring on. For example, if you have threads, both a and b are to increase a shared counter C , then you can see that case Where the value of a c reads, then reads the value of b to c , then A overwrites C with C + 1 , then B with overwrite C Code> C + 1 . Note that C only really increases once!

  • Avoiding running conditions in some normal way include synchronization , which does not have access to a shared state, or in any shared state. But this is just a tip of iceberg - thread-protection is quite a widespread topic.

I hope that helps! Understand that this was a very quick introduction to some of the things that requires a good part of learning. I recommend finding a resource about multidiscipling in the language of your choice, whatever happens, and read it completely.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -