Chandrahas Tore

Greenhorn
+ Follow
since Oct 05, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chandrahas Tore

Client doesn't get output when local address is replaced by server address and client is run from other machine.

Below code works fine when Client and Server are running on same machine but when client runs from other machine with Server's IP address, Client doesn't get any output.

TestClient.java



TestServer.java



Can someone reply where it's going wrong?

Thanks in Advance
- Chandrahas

Originally posted by Sravan Kumar:

Well, doesn't the output seem familiar?

x >>> n is equivalent to (x/2^n)[/QB]



Hi Sarvan,
Your above statement is not right.
See,


This will print 2. The >>> operator is not like << which is multiplication by 2^n.
Hi,

If you want your class to use threading & at the same time extend from other class then you can't use Thread class since java doesn't support multiple inheritance. To overcome this you can implement Runnable & extend from other class. For example, if you are creating applet & want to use threading. Second thing is that Runnable contains single method run() which is executed when thread gets CPU, so you have to override only run() method & you can use other methods of Thread class.

The start() method puts the thread in ready state & calls run() when it gets CPU & becomes running. If you directly call run() method it will not start thread.
Hi,

The first for loop executes for ten times from 0..9, so the output 0..9

In the second for loop no conditional expression is specified. When you don't specify conditional expression in for loop it is always evaluated true. So this is infinite for loop & hence the constant output go

Hi Abhijit,

To answer this question you first need to know what is multitasking. It means a multiple tasks can be runned in a single process/program. It's different from multiprogrammimg. To achieve multitasking a process creates multiple threads. These threads then do a particular job/task. So at a time a thread can do a single task. Hence threads are not multitasking.

since you are catching IOException which is never thrown in corrosponding try block compiler will give error saying "IOException never thrown in corrosponding try block". For this code to compile you have to either throw IOException or use any method which throws IOException like,

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
br.read();

Then it will compile