I'm trying to write a java message switch application by using a multi-threaded server and two clients. However I'm stuck at one point as error occurs when I try to run my programmes. Here are my codes for the server:   public class EchoServer extends Thread {  private static ServerSocket serverSocket; private static Socket connection1; private static Socket connection2; private BufferedReader input; private PrintWriter output; final static int portNumber = 4434;  public EchoServer(Socket in,Socket out) throws IOException{      connection1 = serverSocket.accept();      connection2 = serverSocket.accept();      input = new BufferedReader(new InputStreamReader(in.getInputStream()));     output = new PrintWriter(out.getOutputStream(),true); }  public void run() {     String inputLine;          while((inputLine=input.readLine())!=null){             if(inputLine.equalsIgnoreCase("quit"))                 break;             System.out.println("received:" + inputLine);             output.println(inputLine);         }             System.out.println("received quit,exiting");     }  public static void main(String args[]){               serverSocket = new ServerSocket(portNumber);          System.out.println("listening on port:"+ portNumber);          EchoServer echoserver1 = new EchoServer(connection1,connection2);         EchoServer echoserver2 = new EchoServer(connection2,connection1);         echoserver1.start();         echoserver2.start();      } }   I also wrote two classes for client. When I run the server and then the first client, they work as expected. However when I try to run the second client, a NullPointerException is thrown, regarding to the following two lines:          input = new BufferedReader(new InputStreamReader(in.getInputStream()));         EchoServer echoserver1 = new EchoServer(connection1,connection2);   I know it's a rather long piece of codes to look at, but I'm really stuck as I can't see the problem here. The earlier single threaded version of server I wrote worked without error, so I know there's something to do about the multithreaded. Any help and advice is really appreciated. Thanks!
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
Looking out into the universe means looking back in time - how does that work? This is a question that has been gnawing on me for many years now. Back a long time ago, as I recall in reference to a scene in a popular science show on TV, I was asked the following.  The claim is that when you look out into the universe, you see the universe as it appeared at some past time. (This follows from the speed of light being finite, and looking at objects by observing their emitted light or other EM radiation.) The amount of time that one looks backwards is equal to the distance to the observed object in light-distance (so looking at something ten lightyears away means you are observing it as it was ten years ago).  Matter moves at a rate of speed less than the speed of light (it has to, since matter has mass, even if miniscule at the atomic level). So $v_{mass} \lt v_{EM}$ (probably significantly less, since $v_{EM} = c$).  So let's say you're looking at an object $10^{10}$ lightyears away by observing something for which $v=c$. To the observer, that object appears as it was $10^{10}$ years ago. But the Earth is much younger than $10^{10}$ years and we established that matter moves at a slower speed than EM radiation, so wouldn't the radiation that was emitted $10^{10}$ years ago long since have passed Earth's current position?  If, say, $v_{mass} = 0.5 \times c$ (a big assumption, but bear with me for a second), it would seem that the radiation emitted $10^{10}$ years ago would have passed Earth's current position $10^{10} - (0.5 \times 10^{10}) = 5 \times 10^{9}$ years ago, around the time when the solar system was still forming. Setting $v_{mass} = 0.25 \times c$ (which seems more realistic) means the radiation would have passed "us" around $7.5 \times 10^{9}$ years ago. So how could we be observing it now?  I'm not sure I'm posing this question in the best possible way (I'll admit I do find the concept somewhat confusing), and I'm sure that there's a simple explanation for it all. Just what am I missing?  I did find  which seems peripherally related but not quite the same thing. Qmechanic brought up  but that question seems to be about whether it is so, not why it is so. Blender is rendering an older version my project Blender is rendering an older version of my project, not the most recent one. I have made it using the Blender Render but it does not want to render in cycles either. A black and grey screen is rendered as if everything is transparent. Checked general camera, lighting and compute devises in case I messed something up but I can't find anything. All my textures and objects look normal, does anybody know what is wrong or what to check?  Ok added link: Why is my toilet bubbling? Last night while my washing machine and sink in the master bath was running, my master toilet started having air bubbles come up.  Then this morning while I was showering I heard bubbles again, and the shower was draining very slowly.  After the bubbles occurred my toilet in the master bath and powder room completely drained of water in the bowl and tank.  What is happening? When applying for post-doctoral and faculty positions you are typically asked for three (sometimes more) reference letters to support your application.    Given that it is competitive out there, it also makes sense to apply for all positions that are good matches to your qualifications and career development goals (in the case of post-docs).  Sometimes this may mean asking for several reference letters (or pre-application "can you support me if required?" requests) in a short space of time.  Also, there may only be a small pool of people (i.e. 3 or 4) who know your work sufficiently well to give an excellent reference.  I have also been told that referees want to help you out, and that there is no reason to fear asking them.  And, that in many cases once a letter is written it can typically be quickly repurposed.  But there must be a breaking point.  How do I manage this without being disrespectful?  How many requests in a given unit of time is too many, or harms my credibility?   I am asking this question in this forum, as I am interested in the norms in the academic world, which are often somewhat different than the rest of the working world. How can I type special symbols on my Android device like ☺ or ♥ as a regular character? PHP generate file for download then redirect Why is time special? In Special Relativity, the spacetime interval between two events is $s^2 = -(c{\Delta}t)^2+({\Delta}x)^2+({\Delta}y)^2+({\Delta}z)^2$ giving the Minkowski metric $\eta_{\mu\nu}=\text{diag}(-1, 1, 1, 1)$. What is the justification for making time have a negative coefficient, and how closely is that related to the 2nd law of thermodynamics? Sure, by letting $\eta = \text{diag}(1, 1, 1, 1)$, we get a pretty boring spacetime, and the boosts in the Poincaré group become trig instead of hyperbolic functions, but what's the physical reasoning behind this? Tufte advocates to "minimize the ink-to-data ratio" for charts. I am trying to style a multi data series bar chart, that can have a grid and axes as shown below (chart at the left is from the Economist and on the right my attempt).      Here is the code:  \documentclass[justified]{tufte-book} \usepackage{pgfplots,lipsum} \pgfplotsset{compat=newest} \begin{document} \section{Bar Charts}  \lipsum[1-2]\vfill   \begin{figure*}[htbp]   \fbox{  \begin{tikzpicture}   \centering   \begin{axis}[         ybar,           title={Cumulative Progress of Works},         height=8cm,         width=15.5cm,         bar width=0.4cm,         ymajorgrids, tick align=inside,         enlarge  y limits={value=.2,auto}, % see the upper          ymin=0,         ymax=100,         axis x line=bottom,          axis y line=right,         %enlarge x limits =e,         legend style={at={(0.5,-0.2)},         anchor=north,legend columns=-1},         ylabel={Percentage (\%)},         symbolic x coords={            Sep-11,Oct-11,Nov-11,Dec-11,            Jan-12,Feb-12,            Mar-12,           Apr-12},        xtick=data,        nodes near coords,        every node near coord/.append style={         anchor=mid west,         rotate=70       }     ]     \addplot coordinates {       (Sep-11,75.4064)       (Oct-11, 72.7961)        (Nov-11,94.4597)       (Dec-11,66.6786)        (Jan-12,67.5600)        (Feb-12,88.2339)       (Mar-12,78.6138)        (Apr-12,58.9129) };    \addplot coordinates {       (Sep-11,75.4064)       (Oct-11, 89.7961)        (Nov-11,94.4597)       (Dec-11,76.6786)        (Jan-12,77.5600)        (Feb-12,78.2339)       (Mar-12,88.6138)        (Apr-12,78.9129) };    \addplot coordinates {       (Sep-11,75.4064)       (Oct-11, 89.7961)        (Nov-11,94.4597)       (Dec-11,76.6786)        (Jan-12,77.5600)        (Feb-12,78.2339)       (Mar-12,88.6138)        (Apr-12,78.9129) };      \legend{First Fix,Second Fix,Third Fix}   \end{axis}   \end{tikzpicture} }  \caption{\protect\raggedright Cumulative progress for all MEP works. Notice the slower rate of production during the last three months.} \end{figure*}  \lipsum[1-3] \end{document}   I have moved the y-axis to the right, but cannot get rid of the axis line. The plot is also not fitting within the plot width, despite using \enlarge.   Edit  And thanks to Jake the ugly duckling has been transformed to the following, with minor variations to the code as suggested by Jake. I have only added a stronger color for one of the bars in order to highlight it: How to prove that the set of rational numbers are countable? Can any one tell me how to prove that the set of rational numbers are countable? Prove give me a prove?  Thanks. Show that the rings $2\mathbb{Z}$ and $3\mathbb{Z}$ are not isomorphic. It is discouraged to simply catch System.Exception. Instead, only the &quot;known&quot; exceptions should be caught. Now, this sometimes leads to unnecessary repetitive code, for example: try {     WebId = new Guid(queryString[&quot;web&quot;]); } catch (FormatException) {     WebId = Guid.Empty; } catch (OverflowException) {     WebId = Guid.Empty; }  I wonder: Is there a way to catch both exceptions and only call the WebId = Guid.Empty call once? The given example is rather simple, as it's only a . But imagine code where you modify an object multiple times, and if one of the manipulations fails expectedly, you want to &quot;reset&quot; the object. However, if there is an unexpected exception, I still want to throw that higher. I just learned about the Monty Hall problem and found it quite amazing. So I thought about extending the problem a bit to understand more about it. In this modification of the Monty Hall Problem, instead of three doors, we have four (or maybe $n$) doors, one with a car and the other three (or $n-1$) with a goat each (I want the car).  We need to choose any one of the doors. After we have chosen the door, Monty deliberately reveals one of the doors that has a goat and asks us if we wish to change our choice.  So should we switch the door we have chosen, or does it not matter if we switch or stay with our choice?  It would be even better if we knew the probability of winning upon switching given that Monty opens $k$ doors. I bought an audio book from audible and want to convert it to mp3 from aa because my phone doesn't support the format. Is there any way to do that? Java. Splitting a multiple word string into two word strings every space how to get a picklist all values in apex controller I'm a citizen of an EU member state traveling to a small city in Vermont. Looking at flight data, it seems that it would be quite a bit quicker to fly into Montreal (Canada) and then drive a rental car to my final destination in Vermont (and back), rather than getting a connecting flight into a small local US airport. I am slightly worried about the trouble I might get myself into by crossing a land border twice, though.  Can anyone give me an idea of what I'd be getting into in terms of:   Crossing time Discomfort Additional paperwork required   For both the outbound (Canada/US) and the return leg (US/Canada) of my journey, when compared to crossing the border at an international airport?  Also, do I need to take any special actions when I'm arranging a rental car if I intend to drive it over to the US and back? I hope someone can help me.  I am currently on holiday for 3 months in America under the Visa Waiver Program and would like to stay an extra 2 or 3 weeks. I know I will have to leave the country, renew my visa waiver and then reenter and so wanted to know if I will have an issue reentering.  I will only be out of the country for about 24 to 48 hours, just enough to renew the visa and get on a plane. I understand it is up to the border control person on the day, but does anyone think I will have an issue?? What "exactly" happens when someone turns to the Dark Side? When I saw the original Star Wars saga as a kid, the concept of the Dark Side imprinted in me was quite simple. You did a bad thing, so you're a bad person so you go to the Dark Side and keep doing bad things.  Now, obviously this doesn't hold true in reality. In my mind it is perfectly reasonable for Luke to kill the Emperor and Vader and then just flee the Death Star and rejoin the Alliance. After all they are at war, those are enemy officers that have captured him and are taunting him by threatening with death of all loved ones and the whole operation was intended to kill the Emperor anyway.   The same would hold true for Anakin. He could have killed Mace Windu to save the Chancellor and Padme but that doesn't mean he's going to then go mad and kill all Jedis including children. It doesn't add up from a merely psychological point of view. He had a set of objectives and that made him want to keep the Chancellor alive (quite valid by the way, Mace Windu is quite clumsy on that) but just after killing him he goes into "Yes master I'll do whatever you say" which from a normal point of view will NEVER ever make sense.  In both cases it seems like the assumption is once you use the Dark Side you completely turn to the Dark Side and become a different person that you were before. That would be coherent with Anakin "dying" and Vader being born.  Is that the way the Dark Side works? Is there any canon information about what happens when someone turns to the Dark Side? Specifically to whether they become a different person or how he or she actually changes?  Note: Vader is angry after he finds out Padme is dead, even though he's already turned.  Example of what I mean. In Buffy they explain how people that turn into Vampires lose their soul and it's taken over by a demon, and thus they are, in all effects, a different person with their memories. It  to disable internet search results in start menu searches before the Windows 10 Creators Update, but I've just clean installed a new Windows 10 Pro image and that setting is gone. Is there some way to disable it through editing the registry/etc? Linear Matrix Inequality of a matrix $T$ with $\| T \|_2 < \rho$ Assume $T \in \mathbb{R}^{d\times d}$. Let $\rho(T)$ be the spectral radius of $T$ and $\rho \ge 0$. Prove that  $\rho(T) &lt; \rho$ if and only if there exists a $P \succ 0$ satisfying $T^TPT - \rho^2 P \prec 0$.  I can prove the Necessity: If $P = I$, for any $x \in \mathbb{R}^d$,   \begin{equation} x^T T^T P T x - \rho^2 x^T P x = \| Tx \|^2 - \rho^2 \| x\|^2 &lt; 0 \end{equation} so $T^T PT - \rho^2 P \prec 0$  I get stuck in proving the Sufficiency.