Men Gumani

Ranch Hand
+ Follow
since Apr 01, 2009
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 Men Gumani

I guess I only need to print out a list of urls for all the blocks on a given date, so I only have to traverse the whole log file once(not too sure), is there anything interesting about the order of the token I should process? e.g. if I process <status> first then check the <date> will it be faster? I am not sure if I can use a good algorithm and cause better performance, thank you.
14 years ago
Hi all,


I am trying to parse a log file which contains 4 columns, <date> <time> <status> <name>, <status> column only have 2 candidates, "run" or "sleep", what is the efficient way to print a list of names for all <status> equals to "run" on a given date? Any hints will be appreciated, thank you so much guys!
14 years ago
Thanks, Devaka. I don't want to dig deep into the details, I am just curious about the statement in the book "at any given time the current running thread usually will not have a priority that is lower than any of the thread in the pool" is not completely right since even the priority of the running thread is changed to be lower than some of the threads' in the pool, as long as the time slot is not expiring, the current running thread will not return the control back to the scheduler and it is running with a lower priority than some thread in the pool.
Please forgive my ignorance.
Hi guys,
I have a quick question about thread priorities, it is saying that "the runnning thread will be of equal or greater priority than the highest priority threads in the pool", my question is, if the scheduler give the control to some thread and during that time slot some other thread's priority value is bumped to be higher than the current running thread, is the control immediately returned from the running thread back to the scheduler or the thread will finish the current time slot allocated to it and then return the control to the scheduler?
Thanks.

confuses me.


this should produce the output of 5 instead of 10 and the order should not matter should it?

Aside, I vaguely remember that some variable will be assigned a value after the constructor is called,

is the following flow correct when you create a new trial object?
1) give i a default value 0
2) run the constuctor
3) assign 5 to i since constructor does not initialize i
sounds weird to myself

Ruben Soto wrote:Men, you are going to have to be more specific about what you mean by dynamic cast.


(((Animal)someAnimal).checkup()) in C++(might be different syntax), will acturally use animal's checkup method instead of cat's?

Ruben Soto wrote:.... all local variables are destroyed (but a copy of final local variables is provided for method local inner classes.) ....


Can you please explain more about how final variables are stored in the stack and why it will not be destroyed after method ends?

Ruben Soto wrote: ..... If the method has reference local variables, and the objects which they point to are not pointed to by any other reference variable, then the objects themselves will become eligible for GC....


I thought the inner class object will have its own reference variable point to the same object as the local reference variable pointed to, since the inner class object is alive, the object will not be recycled by GC.

Thank you Ruben.
I don't know if my understanding is right, it would be really appreciated if you could correct me:
Here is my understanding:
1) when method ends, the stack for the method is gone, the memory address storing the value of the method's local variable will be used for something else whereas the method-local object is still alive and reference to that memory address, which causes the corruption.
2) If the method's local variable is marked as final, the method-local object will have a different variable stored in the heap reference to the same memory address in the stack and this memory address in the stack will not be recycled when method ends .
Here is the question:
From what I can see is that ONLY primitive local variables will be re-cycled after the method ends, the reference variables declared in the method will still be usable since the object they are referencing to is in the heap and after the method-local object is created, they have there own reference variable refer to the object in heap and it will not be recycled. It seems like restricting user from using primitive local variables only will suffice, is it?
A friend of mine told me that C++'s dynamic cast can do this by changing the pointers in the v table , is that true? Is there similar things in Java? I used to think the cast in Java is dynamic cast. Thanks~
Hi all,


Is there a way that I can use Animal's checkup method on a Cat object?
Hi all,

The book is telling me that "the inner class object can not use the local variables of the method the inner class is in", the reason for that is the inner object might still be alive but the local variable is gone when the method ends. My question is: if the inner class can only be used by this method, how is it possible to pass this inner class object reference to some other code? Does it mean there could be two or more identical classes and one of them is an method-local inner class? Are there any use cases to pass method-local objects into some other code?

Thanks.