I want to count Words with several Threads and every thread has a "wordCount" variable. Now how can i wait till every thread is finished? At the end i should count every variable of each thread together and print it out?  How i create my Threads:  for (int i = 1; i &lt;= THREADS_TO_USE; i++) {     long bytesToRead = splitManager();     new Thread(new CountWordsThread(file, bytesToRead, bytesCounted)).start(); }
I'm making a Java application with an application-logic-thread and a database-access-thread. Both of them persist for the entire lifetime of the application and both need to be running at the same time (one talks to the server, one talks to the user; when the app is fully started, I need both of them to work).  However, on startup, I need to make sure that initially the app thread waits until the db thread is ready (currently determined by polling a custom method dbthread.isReady()). I wouldn't mind if app thread blocks until the db thread was ready.  Thread.join() doesn't look like a solution - the db thread only exits at app shutdown.  while (!dbthread.isReady()) {} kind of works, but the empty loop consumes a lot of processor cycles.  Any other ideas? Thanks.
I just edited an answer on Unix&amp;Linux and when scrolling down, the semi-transparent right sidebar boxes "How to edit" and "How to format" kept their fixed positioning and overlapped with the page footer.     While posting this, I have seen several (not) duplicate questions about this issue, and although from my personal taste, I would prefer the boxes to stop scrolling before the footer is reached, I can accept the development teams decision to let it overlap.   However, on all those other posts, the boxes had an opaque background, so that the footer was hidden and the box content was readable. Here the boxes are transparent though, so the texts get mixed and are no longer well readable. A machine is described as being "really slow" or "freezing". How can I troubleshoot/resolve this issue? What should be the first steps to take? How can I move an installed game from one Steam library folder to another? I use (and have it much bigger) drive D: to store all my user data and games, but I have installed the Steam client on drive C:. When I was installing a first game (Warhammer 40000), I've chosen to place my library folder on drive D: and the game went there.  But now as I've got installed the second game (Portal), I can see that it was put on drive C: despite to the choice I've done previously. When I open Steam - Settings - Downloads + Cloud - Steam library folders, I can see both installation places in the list. Can I merge them into one?  I would even agree to use the default drive C: library (as I've replaced it with a symlink already). When I press to remove one library it says it can only remove empty ones. I currently have a setup where I send a char using a Tx of 434MHz and an Uno to a Mega with a Rx. The Mega counts how many times it receives the char and then if it falls below a certain number it triggers an alarm. Is this a viable way to measure the distance between two microcontrollers while indoors or is there a better way.  Transmitter (Mega)  #include &lt;SoftwareSerial.h&gt;  int rxPin=2; //Goes to the Receiver Pin int txPin=5; //Make sure it is set to pin 5 going to input of receiver  SoftwareSerial txSerial = SoftwareSerial(rxPin, txPin); SoftwareSerial rxSerial = SoftwareSerial(txPin, rxPin); char sendChar ='H';  void setup() {   pinMode(rxPin, INPUT);   pinMode(txPin,OUTPUT);   txSerial.begin(2400);   rxSerial.begin(2400); }  void loop() {   txSerial.println(sendChar);   Serial.print(sendChar); }   Receiver  #include &lt;SoftwareSerial.h&gt;  //Make sure it is set to pin 5 going to the data input of the transmitter int rxPin=5;  int txPin=3; //Don't need to make connections int LED=13; int BUZZ=9; int t=0;  char incomingChar = 0; int counter = 0;  SoftwareSerial rxSerial = SoftwareSerial(rxPin, txPin);  void setup() {   pinMode(rxPin, INPUT); //initilize rxpin as input   pinMode(BUZZ, OUTPUT); //initilize buzz for output   pinMode(LED, OUTPUT); //initilize led for output   rxSerial.begin(2400); //set baud rate for transmission   Serial.begin(2400); //see above }  void loop() {   for(int i=0; i&lt;200; i++) {     incomingChar = rxSerial.read(); //read incoming msg from tx      if (incomingChar =='H') {       counter++; //if we get bit "h" count it       }     delay(5); //delay of 10 secs   }   Serial.println(incomingChar);   Serial.println(counter); //prints the the bits we recieved    if(counter&lt;55) {     //if we receive less than 100 bits than print out of range triggers alarm     Serial.println("out of range");      tone(BUZZ,5000,500);digitalWrite(LED,HIGH);   }   else {     noTone(BUZZ);digitalWrite(LED, LOW);     //if we get more than 100 bits than we are within range turn off alarm     Serial.println("in range");    }    counter = 0;   incomingChar=0; } Do Wine Viruses only work while Wine is running? I heard Linux can get viruses through Wine,and I was curious if the viruses work only while Wine is running.  In other words, could I stop a virus from doing it's thing by just quitting Wine? Contraction Map on Compact Normed Space has a Fixed Point Infinitely number of primes in the form $4n+1$ proof Question: Are there infinitely many primes of the form $4n+3$ and $4n+1$?  My attempt: Suppose the contrary that there exist finitely many primes of the form $4n+3$, say $k+1$ of them: $3,p_1,p_2,....,p_k$  Consider $N = 4p_1p_2p_3...p_k+3$, $N$ cannot be a prime of this form. So suppose that $N$=$q_1...q_r$, where $q_i∈P$  Claim: At least one of the $q_i$'s is of the form $4n+3$:  Proof for my claim: $N$ is odd $\Rightarrow q_1,...,q_r$ are odd $\Rightarrow q_i \equiv 1\ (\text{mod }4)$ or $q_i ≡ 3\ (\text{mod }4)$  If all $q_1,...q_r$ are of the form $4n+1$, then $(4n+1)(4m+1)=16nm+4n+4m+1 = 4(\cdots) +1$  Therefore, $N=q_1...q_r = 4m+1$. But $N=4p_1..p_k+3$, i.e. $N≡3\ (\text{mod }4)$, $N$ is congruent to $1\ \text{mod }4$ which is a contradiction.  Therefore, at least one of $q_i \equiv 3\ (\text{mod }4)$. Suppose $q_j\equiv 3\ (\text{mod }4)$  $\Rightarrow$ $q_j=p_i$ for some $1\leq i \leq k$ or $q_j =3$  If $q_j=p_i≠3$ then $q_j$ | $N = 4p_1...p_k + 3 \Rightarrow q_j=3$ Contradiction!  If $q_j=3$ ($\neq p_i$, $1\leq i \leq k$) then $q_j | N = 4 p_1...p_k + 3 \Rightarrow q_j=p_t$ for some $1 \leq i \leq k$ Contradiction!  In fact, there must be also infinitely many primes of the form $4n+1$ (according to my search), but the above method does not work for its proof. I could not understand why it does not work. Could you please show me?  Regards Calculate all integer solutions $(x,y,z)\in\mathbb{Z}^3$ of the equation $x^2+y^2+z^2 = 2xyz$.   My Attempt:  We will calculate for $x,y,z&gt;0$. Then, using the AM-GM Inequality, we have  $$ \begin{cases} x^2+y^2\geq 2xy\\ y^2+z^2\geq 2yz\\ z^2+x^2\geq 2zx\\ \end{cases} $$  So $x^2+y^2+z^2\geq xy+yz+zx$. How can I solve for $(x,y,z)$ after this? How do I configure swappiness? Do people sometimes get blocked by a webservice for things someone else has done with their dynamic IP-Address It is common practice for operators of web services (e.g. web sites) to block IP addresses when there was malicious traffic originating from that address.  It is also common practice that internet users don't have a static IP address but get one assigned by their ISP via DHCP.  Now I would expect that it sometimes happens that a specific IP address gets banned from a service and later that address gets assigned to another user, leaving the new user (temporarily) banned from the service for no apparent reason. However, I never had this problem or heard of someone having that problem.  Does this sometimes happen? If not, what prevents this from happening? nginx open reverse proxy? Where do I find out how a command/environment is defined? Say I want to redefine the itemize environment, or make a modified version of it. I want to know how it is currently defined. Where do I find this information? If it's some particular package command, I can just look at the .sty file for that package, but if it's something more basic, I don't know where to look...  Is there a reference manual of where all this stuff is explained? Or is there a file in the depths of my texmf tree I should poke around in? (Automatic Bike Project) amount of torque required to change gears? I am planning to build an electronically controlled automatic bike transmission for my senior design project. I'm personally more of an electrical guy, so dealing with the mechanics is somewhat new to me. I would have loved to use an off-the-shelf electronic derailleur, but alas, they are too cost prohibitive (the school has allotted a budget of $115 per student and we're a group of two, so we have $230 to spend). So I'm going to need to make my own like several other people have done.  I am planning on using the bike's current derailleurs and replacing the hand shifters with motors of some sort to pull on the cables. Of course, we're going to need a certain amount of torque to shift up (and much less for shifting down) and a holding torque to ensure that we don't accidentally slip down a gear.   I have not bought a bike yet, I'm looking at a Diamondback bike that I found on Craigslist (it looks like a hybrid bike). So I'm wondering if there are any average measurements for the required torque.  And of course, I'm sure there are many people more experienced in bicycling than I am. So if you have a better solution, please feel free to shout it out. I'm all ears. Number of publications needed to get into a computer science PhD program? I've looked at the resumes of the type of candidates that get into computer science PhD programs at the top few universities (e.g. Stanford, MIT etc.) and a lot of them seem to have multiple publications (2-4) done during their undergraduate years. Is this representative of the entire pool? Or is this just a self-selected group that puts their resumes online.  I currently have one first-author workshop paper (5 pages), and I wonder how this might affect my chances at entry into these top universities. How do I set up SSH so I don't have to type my password? How do I set up SSH so I don't have to type my password when connecting to a host? I have a div 200 x 200 px. I want to place a 50 x 50 px image right in the middle of the div.   How can it be done?  I am able to get it centered horizontally by using text-align: center for the div. But vertical alignment is the issue.. Show that there are $ a,b \geq 0 $ so that $ |f(x)| \leq ax+b, \forall x \geq 0.$ $f$ has the form $f(x) =ax^2+bx+c$. Every differentiable function $f:R \rightarrow R$ with the property that $(2h)f′(x) =f(x+h)−f(x−h)$ for all $x \in R$ and all $h$ has the form $f(x) =ax^2+bx+c$.  I would like to get some help on this one. Taking partial derivatives was an idea, but is that legal? Given a field $F$, can you necessarily construct a field extension $E \supset F$ such that $\operatorname{Gal}(E/F) = S_n\,$? As linguistics student, I have to put more than one thing on a character every now and then. For example, I need to type ā̆. I thought I could simply do that by typing \={\u{a}}, but then the macron is placed above an empty space in front of the character.  How can I solve this? Thanks  P.S. I'm using MiKTeX 2.9, running on Windows 8; in case it might be of use.