Note that there are some explanatory texts on larger screens.

plurals
  1. POQuestions on Concurrency from Java Guide
    primarykey
    data
    text
    <p>So I've been reading on concurrency and have some questions on the way (<a href="http://docs.oracle.com/javase/tutorial/essential/concurrency/index.html" rel="nofollow">guide I followed</a> - though I'm not sure if its the best source):</p> <ol> <li>Processes vs. Threads: Is the difference basically that a process is the program as a whole while a thread can be a (small) part of a program?</li> <li>I am not exactly sure why there is a interrupted() method and a InterruptedException. Why should the interrupted() method even be used? It just seems to me that Java just adds an extra layer of indirection.</li> <li>For synchronization (and specifically about the one in that link), how does adding the synchronize keyword even fix the problem? I mean, if Thread A gives back its incremented c and Thread B gives back the decremented c and store it to some other variable, I am not exactly sure how the problem is solved. I mean this may be answering my own question, but is it supposed to be assumed that after one of the threads return an answer, terminate? And if that is the case, why would adding synchronize make a difference?</li> <li>I read (from some random PDF) that if you have two Threads start() subsequently, you cannot guarantee that the first thread will occur before the second thread. How would you guarantee it, though?</li> <li>In synchronization statements, I am not completely sure whats the point of adding synchronized within the method. What is wrong with leaving it out? Is it because one expects both to mutate separately, but to be obtained together? Why not just have the two non-synchronized?</li> <li>Is <em>volatile</em> just a keyword for variables and is synonymous with synchronized?</li> <li>In the deadlock problem, how does synchronize even help the situation? What makes this situation different from starting two threads that change a variable?</li> <li>Moreover, where is the "wait"/lock for the other person to bowBack? I would have thought that bow() was blocked, not bowBack().</li> </ol> <p>I'll stop here because I think if I went any further without these questions answered, I will not be able to understand the later lessons.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload