This is in continuation of my first post HERE about the java interview questions I have come across.
1. What are Threads in JAVA and in what ways we can create them?
A. A Thread is defined as an independent path of execution in a program. A program in java can have many threads running concurrently, either synchronously or asynchronously. The threads are defined by java.lang.Thread class. There are two ways of creating a thread.de
a. Extend Thread class : In this method, the user defined class extends ‘Thread’ class and override ‘run()’ method in it.The ‘start()’ method is inherited from the Thread class and is invoked on the object of the user defined class to make the thread start executing.
class MyClass extends Thread{
MyClass() {}
public void run(){
System.out.println("Thread initiated...");
}
public static void main(String[] args){
MyClass obj = new MyClass();
obj.start();
}
}
b. Implement Runnable Interface: In this method, the user defined class implements the ‘Runnable’ interface and implement ‘run()’ method in it. An object of the ‘Thread’ class is created by passing a Runnable object as an argument to the Thread constructor. The Thread object will then have a Runnable object that implements ‘run()’ … Read the rest
By the end of this weekend, one questions looms morbidly over my sorry mental state. Will I ever be able to make a schedule or time sheet that I will be able to adhere to, or is the whole concept of proper time management immensely overrated and it eventually comes down to how less one can mis-manage their time. After having tried time and again to set a routine and following it, I have, for myself, come to terms with the fact that I am not comfortable with defining everything by a deadline. There surely the professional commitments that I, obviously, try my best to deliver on or before the deadline but here I am talking about jotting down the whole schedule, lets say, for a week which includes everything from the time to be spent in morning workout, breakfast, work schedule, pursuing hobby to the time spent with friends and family. Even after figuring out a schedule that encompassed everything I had on the agenda, at least on paper, I couldn’t follow it for certain of things. … Read the rest
How many times have you witnessed an argument where you, in your mind, were able to comprehend the points being made by the opposing parties more clearly than their counterparts were. Where you were so sure that if it were you as one of the sides, then the conclusion would’ve been arrived at much sooner, or even instantly. Where, to you, it all seems like a incessant drone and ramblings of lesser brains who are not capable of making heads or tails out of the issue and where, in short, you see everything as clear as a crystal and hence wonder, why can’t they?
After being a part of both of the sides for a very long time, and actually consciously realizing it only recently, and mulling over it for past couple of days, I came to the conclusion that most of the times an argument can be avoided or rather concluded in short order if the arguing parties agree to a few basic rules. I was, from my experience, able to narrow it down to only two. Topic and Subject. At the first glance, these two might seem to be related closely, or even same but trust me, they … Read the rest
It seems like ages since I put down my ongoing experiences in black and white and hence, as might have been guessed, the title. I am pretty sure that more such entries will follow though, obviously, I do not intend to do so. Keeping a journal/blog, I have realized, is very much like making a new year resolution. The rest, as they say, becomes history. Anyway, I had reasons for keeping away from this, rather reasons that kept me away until today I finished off with with something I had been trying to do for past two days. The task, which was syncing about 150 gigs of music to my new iPod ended up me installing/reinstalling numerous ipod softwares on four systems, and two virtual machines, corrupting one of those, consuming hours and hours at end and finally, eventually but gradually finding one piece of software that does the job on my linux box. I will delve into those details in some other post. It also is quite evident to me that almost all of the readers will be quite wondering as to what can possibly go wrong with such a simple task which many of them perform almost daily. … Read the rest
After spending about 8 hours yesterday on trying to resolve an eccentric behavior, I finally ended up realizing that its the property/issue/bug of the APK installer of Android 2.2 in my device and after performing the same test on about 5 different apps, I concluded that this was definitely not the issue with my app, but with either the device(HTC Desire) or droid 2.2. Still have to test it on other devices(as soon as I get my hands on one).
It goes on something like this, and the steps could be followed for installing any application.
1. Install the app from any source (market/sdcard/download from site).
2. When the installation is complete, it shows the dialog which says ‘Installation Complete’ and you have and option to ‘Open’ the app or ‘Ok’ to return to home or wherever you came from.
3. At this point, press ‘Open’ to (obviously) open the app. Now you have the home screen of the app.
4. Press your ‘Home’ key to return to the android home screen. Now the app you just opened should be running in background.
5. Now go to the applications menu and click the launcher (icon) of this very app which … Read the rest