Ashish Agnihotri

Ranch Hand
+ Follow
since Nov 16, 2000
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 Ashish Agnihotri


Hi everybody,
What is difference between absolute, relative and canonical path of file or directory ?
tks in advance,
Ashish

Hi Jane / Anybody else
The question still remains why ?
pl answer.. getting a bit curious...
tks,
Ashish
Hi Jane,
juz check this thing out. I have added a few System.out's to your code.
class Waiter extends Thread {
public synchronized void run() {
try {

System.out.println("thread Waiter Starts");
wait();
} catch (InterruptedException ie) {
System.out.println("Interrupted.");
}
System.out.println("Waiter back in control.");
}
}
class Notifies extends Thread {
public synchronized void run() {
System.out.println("Notifier running.");
try {
System.out.println("Going to sleep.");
Thread.sleep(100);
System.out.println("Woke up.");
}catch (InterruptedException ie) {
System.out.println("Interrupted.");
}
System.out.println("Back to waiter.");
notifyAll();
System.out.println("going to awake");
}
}
public class Waiting {
public static void main(String[] args) {
Thread waitThread = new Thread(new Waiter());
waitThread.start();
Thread notifyThread = new Thread(new Notifies());
notifyThread.start();
}
}

AFTER THE CODE IS RUN : it never prints "going to awake" and does not go back to "thread Waiter Starts"...
tks,
Ashish

Bill !!
This is real good one. Something which I tend to overlook always. Good to know you run last 10-15.. you are better than me !!
tks,
Ashish

Hi Sree !!
Are you a tutor !!
Excellent explanation.
tks,
Ashish

Oh yeah !
A thing has juz struck me. Should have not wait/notify be called on both the threads exclusively.. !! I guess thats why such behaviour !!
any comments !!
tks,
Ashish
Hello,
I am able to download correctly. Zipped file size is 155KB.
But cant run ... problems !!
I use JDK1.3
suggestions ?
tks,
Ashish

Hi Randall
only a small change... typo error !!
Instead of Thread notifyThread = new Thread(new Notifier());
it shud be
Thread notifyThread = new Thread(new Notifies());
One question :
Output comming is :
Notifier Running
Going to Sleep
Woke Up
Back to Waiter !!
My question is after notifyAll() the program HANGS !! I mean it waiting in loop or something like that !!
why is it so...becoz shouldnt it actually bring the waiting thread ( Waiter class) back to running when notifyAll() is invoked in code !!
please explain :
tks,
Ashish
tks,
Ashish

Hi everybody !
I was juz reading and came up with a statement .. which goes like..
== GIVES COMPILER ERROR if the operands are cast incompatible.
This is true !! but my question is different..
Is there an easier way to understand when there will be compiler error and when runtime... Ofcourse there is a clear definition, I was wondering is there are some rule of thumbs !!
Is it that anything which violates JLS will cause compile error. If that is so.. is everybody supposed to know everything right away !! I mean its quite huge.. and few things we learn with time ( as we work ). Also from exam point of view....
tks,
Ashish

Is Container an abstract class ?
I read that it WAS in Java 1.0 and 1.1 but not in JDK 1.2
but again somewhere I read it is .. still !!
anyway we more use java.awt.Panel, java.applet.Applet in actual programs.. still want to know..
tks,
Ashish

If everything we post were to be correct... then why have this a discussion forum...
If everything is 100 % which is posted here .. isint it a great idea for all of us to earn good money by archiving all POSTS and binding it into a good looking book and selling it in our respective countries !! with a vogue name ofcourse, "Java discussed on breakfast table"....
Well seriously I believe everybody comes here to share what they feel.. some are careful to check and then post , while few are a bit fickle and post what they think. Personally I think we need both kind of people to make this JAVA FORUM A HAPPY AND LIVELY PLACE.
Finally if one were to Succeed , he/she better have a texeditor and JDK on ones machine...along with active participation in this "revered" forum. Then there's gonna be no stopping either in JCP or anything.
tks,
Ashish

Remember !! IMPLICT call to super class is always without arguments. So naturally if there is a constructor which takes an argument... will not be called IMPLICITLY.
Also if you have only one constructor in super class and it takes an argument than not calling it explicitly in the subclass will give compile time error.
In such cases u have to make EXPLICT call using SUPER and passing necessary arguments.
HTH,
Ashish

Michel,
You said "when method is declared Static and Synchornized... only one thread (person) can access at any given point of time"
Does this mean all other methods in the class are also locked. Then it means class at that point ( when the method is used ) is behaving as Static also .. even if it is not declared !!
Secondly, when method in a class is non-Static and synchronized.. you can create instances of that class and then different threads can access that method ( unlike previous one ) .. is this so ?
tks,
Ashish

I think Randall has a point there

Hi Friends,
I think we are digressing from a simple question asked by Binu.. that is it useful to be certified while seeking job in US ?
Lets leave it to him.. how he views JCP. Sorry for being a bit blunt.
My answer to u Binu is YES it makes difference.
tks,
Ashish