Ajit B

Greenhorn
+ Follow
since Jul 24, 2001
Merit badge: grant badges
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 Ajit B

hi dan ........
thanks for your reply......... ya you are right i took the wrong meaning of what Peter was saying.

If you want to be able to restart your code, don't extend Thread, implement Runnable. - Peter


ok so the conclusion is "Thread behave like this cause they are defined in that particular way."
once again thanks for the pain you have taken to answer my query and for your innovative examples.
......... Ajit

hi Peter
thanks for replying......

i have understood that we can't hold the OS resources till the object which was pointing to a thread gets garbage collected. So as soon as the thread finishes its run method , it frees the OS resources. but my question is we still have object alive which was pointing to Thread (with which we earlier called start() method and started the Thread). This object is still there in memory and is not garbage collected even after complete execution of thread. so again when i say threadObject.start() , shouldn't it start new Thread( )? ( OS resources will be freed after its complete execution thats different issue.)
ok and my second question is why there is this difference between Thread and Runnable? why its that when we implement Runnable we can start thread again but the same is not possible if we extend Thread.
eagerly waiting for your reply

........... Ajit
hi all.......
when the thread finishes it's execution why can't we start it all over again? can any one explain me why can't we call the thread's 'start' method more than once? whats the concept behind this?
thx in advance..........Ajit


hi Dave......

In fact after it is done with run() you can still call a Threads methods and access its variables, you just cant start it running again.


dave, can u just tell me why the Threads are implemented that way? why is it that we can call other methods but we can't call Start()? whats that specific reason that Thread has been implemented this way? what harm it cause if i start the thread all over again if it has completed execution?
thx in advance ........ Ajit
hi sandeep.....
try the followong code. it doesn't cut the text even if column length is not enough. In the following code i hv textfield with 0 column length. still it displays text without ne chopping.
i guess coz a column is an approximate average character width that is platform-dependent.

HIH
...Ajit
hi Roopa.....
thx for replying but i think u dint get my question?

JOIN -> Waits for this thread to die.


(its just join() not t1.join().)
i want to ask what happens when u call join on the currentThread?
in the above code i m calling join () on the currentThread. so the thread which called join() waits for the calling thread (same thread which called join() )to finish.

i think if v call join() in run() method of ne thread it acts same as sleep(long mills) ( or sleep(long infinite) as in the 2nd case ).


so isn't it that join() behaves as sleep() when called inside run()???
waiting for reply,
Ajit
hi all.......
if i call the join() method in the run() method of ne thread like the one in following code :

public void run()
{
join(1000);// will halt the execution of this thread for 1 sec

join();// will stop this thread permanantly
}
ok, so i think if v call join() in run() method of ne thread it act same as sleep(long mills) ( or sleep(long infinite) as in the 2nd case ).
is my this understanding is correct?
plz correct me if i m wrong.
thx in advance
.........Ajit
hi Marilyn......
can u gimme examples of System resources,
thx in advance.........Ajit
hi valentin.....

when you write byte b = 99; the compiler knows that a byte variable can hold 99 so it performs an implicit conversion because 99 is a constant literal.


why the same above rule is not applicable to float. When v write float f = 2.0, why implicit conversion is not performed.
thx in advance
.....Ajit
though thread.start() method internally calls run(), it starts the new Thread.
where as if u just call run() method directly it will execute the code with in run method but won't start a new Thread. so there is a difference........Ajit
hi Johannes

thx for replying.........
what u r saying is perfectly ok. i agree with that. but To elaborate bit more on my Q , consider following code.....

now in the above code i hv not extended Graphics2D, still fill method works properly. that means there is some implementation somewhere? so which method of which class is providing it?
hope someone will help me out .......Ajit
21 years ago


when accessing member variable it is always the DECLARED type that counts and not the runtime type...
When accessing member method, it is always the RUNTIME type that counts and not the declared type,


hi Valentin........
just small question. i dint get the reason y java has been implemeted this way.
isn't it mean , when v upcast the object v can call methods of subclass and can call attributes of superclass?
isn't it mean by this way v r losing access to some of public attributes in subclass?
thx in advance
.........Ajit
hi.....
which package u r talkin about?
there is java.lang.Math class, methods of which are all static. Math.method() this is how to call it. Is this answers ur ques ? or i did i miss something ?.......Ajit
hi all.......
int i = 0;
i = i++;
i = i++;
System.out.println( i );
why the output of above code is zero?
i guess it has something to do with internal implementation of post increment operator.
can ne1 explain?
thx in advance..........Ajit
hi all........
public abstract void fill(Shape s)

This is the absract method in class Graphics2D. i tried to search for class which overrides this method in java doc, but cudn't find one.
so all i want to know is where is the implementation of this mehtod? in which class?
..........Ajit
21 years ago