Tuesday, April 27, 2010

Thread.sleep

A thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently.

Yes thats the kind of explanation they give in javadocs... Couldn't gather much from this.
So here's what it is in common mans language
A thread is like a process(Java gurus pls forgive me), the way we start each process on our machine like a firefox browser, a wordpad, media player etc... Now each of this process appears to be occuring simultaneously. Similar is the case of a thread in java.

You could have multiple threads and each of the threads would execute simultaneously or so it appears to be because of the time sharing it does.

Now getting to the topic of discussion what is Thread.sleep and other questions like isn't it a static method?

It is a static method but it gets the thread that is currently executing to sleep for the specified number of milli seconds.

How does it do it?
Using the concept of TLS or thread local storage. Each thread has a global memory which stores information corresponding to itself. So when Thread.sleep is called the stack which is running the thread is suspended and it waits for the time to complete or for some other method to interrupt it so that it can throw and interrupted exception and continue execution.

Difference between Thread.sleep and Thread.currentThread().sleep()
None. There is no difference between the two. Thread.currentThread returns the current thread that is executing don't confuse it with "this" this refers to object, Thread.currentThread refers to the thread being executed currently.

some more on it will come soon... but currently i'm feeling thread.sleeepy...

Sunday, January 10, 2010

Reliance Netconnect Usage

I have been using reliance netconnect night unlimited(so they say with a 10gb limit) plan for some time now.

The most irritating part of using it is that there is no way to find out how much you have used. They have a usage tab wherein they give you the kbs you have used, but do they expect us to add the usage depending on the time we used it and seperate it into night and day usage.

Here is the link where you can calculate the usage by just giving your mobile number and the dates.
It will give you a day and night split of your usage.

Friday, October 23, 2009

Use previously installed Ubuntu after installing XP or Vista

This post explains in a quick fashion how to restore your Ubuntu grub after installing any windows verstion(XP, Vista, 7(dint try but shud work)).

Steps:
1. Install the windows version you need on any partition other than the one on which ubuntu is installed.

2. When you restart the PC you will be automatically logging into the windows version, so you would have to boot using a ubuntu live cd.

3. Once in the ubuntu live cd env open a terminal( application-> accessories -> terminal).

4. Type in as given below without the quotes
"sudo grub"

5. You will log in into a grub shell
grub>

6. Type in "root (hd0,0)"
followed by "setup (hd0)"

7. Keep on trying this with other values

eg.
root (hd0,1)
setup (hd0)

root (hd0,2)
setup (hd0)

root (hd1,0)
setup (hd1)


root (hd1,1)
setup (hd1)

until you get a successful message and not
"Cannot mount selected partition"

8. Once you get the message it means the grub was restored. Type "quit"

9. You will come out of the grub shell.

10. Now restart the machine. You will see the grub at the point of booting, with the ubuntu partition.

Setting up to boot windows.

1. Boot into the ubuntu partition by selecting the ubuntu from the menu.

2. Open a terminal following process given above and type in gksudo gedit /boot/grub/menu.lst

and edit it to boot to your windows partition.

Please post comments or queries if any.

Tuesday, August 4, 2009

SCWCD certified

Long time since i wrote a post. Wouldn't have but this is a news i can't keep to myself. So finally I'm a sun certified web component developer. The preparation was pretty much long, but what really helped me is the experience in my company. This is one exam you need to give after you get a good lot of experience...

Sunday, April 19, 2009

Reliance Netconnect broadband on Ubuntu

Let me first of all make it clear that the activation of your card can be done only using windows so you need to find a windows machine and get your card activated.

Assuming you have activated your card the following are the steps to get it working on ubuntu


Open the Terminal (Application->Accessories->Terminal)

Type SU (Super User, gives administrative privilege will need it little later). Key in the password .

then,

lsusb

Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 003: ID 12d1:1412 Huawei Technologies Co., Ltd.
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

This thing pops Out

Note down the no just before Huawei or quallcom depending on which card you use . To my experience all cards of the same vendor will have the same id. like for Huawei itll be 12d1:1412.

next,

modprobe usbserial vendor=0xAAAA product=0xBBBB ,

Where AAAA is 12d1 and BBBB is 1412 in my case.

Then you have to edit wvdial.conf file, type,

gedit /etc/wvdial.conf

This will open wvdial.conf.

(NOTE: wvdial might not be installed , to install it .
Insert original UBUNTU CD

Go to System->Administration->software sources. add cd as a source and close . itll update itself, Then on terminal type,
sudo apt-get install wvdial .

And key in Ur password , that shall do.

NOW coming back to wvdial .conf. Copy and paste this overriding the previous setting in .

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Stupid Mode = 1
Modem Type = USB Modem
ISDN = 0
Phone = #777
New PPPD = yes
Modem = /dev/ttyUSB0
Username = 9876543210 (This is the no written in the back side and changes in every card).
Password = 9876543210 (This is the no written in the back side and changes in every card and is same as user name).
CBaud = 460800

Save it and exist .

Next,

Just enter terminal and sudo Wvdial
And your password to getconnected.

Best of Luck .

Wednesday, July 9, 2008

Installing Software in Ubuntu (.bin or .sh files)

Though there are many methods for installing files in Ubuntu like System--> Administrator --> Synaptic package manager. Many a times the websites offer .bin (binary) files for softwares. Here I am at giving a short and simple step by step process for installing from binary files.

1. Download the corresponding .bin file. Place it anywhere in your hard disk.
2. Navigate to the folder through the terminal...( using cd path)
3. Start installation by typing sudo ./filename.bin
4. Your root password will be asked. (if you haven't created a root account the password is the same as your login password).
5. Installation will occur on its own.
6. After the execution is over if you type command then the program should start.

eg. To install NetBeans IDE
1. Download the IDE from NetBeans IDE
2. Navigate to the folder containing the downloaded file.
3. Type sudo ./netbeans-6.1-ml-linux.sh
4. A GUI will guide you through the rest of the installation.
5. After the installation is over if you type
netbeans
NetBeans program will start. It also appears in the Applications--> Programming list in the ......

In case of any comments or suggestions please feel free to contact me
at anillraju@gmail.com

Saturday, June 14, 2008

ADSL 502T bridge connection for Ubuntu

For a bridge connection creation for adsl 502 router you require to make two kinds of setup
1. Router setup
2. Dialer setup

Router setup:

It is always best to start of with resetting your router. You can do this by inserting a pen into the routers backside hole which says reset. Assuming that your router has been resetted follow the steps given below to create a bridge connection.
1. After the power, adsl and lan lights are on navigate to page http://192.168.1.1/
2. Log in using username- admin
and password- admin
3. Go to the setup tab.
4. Press create a new connection
5. Select bridge connection instead of PPPoe
6. Select the auto pvc check box.
7. Save the connection.
8. Go to tools and select save all
9. Restart the router.

Dialer Setup:

Though I have tried this on ubuntu and kubuntu, this should also work for other linux installations as well.

1. Open a terminal window.
2. Type "sudo pppoeconf" and press enter.
3. There are some simple questions you have to answer.

Question
3.1 ALL DEVICES FOUND? Yes
3.2 OKAY TO MODIFY Yes
3.3 POPULAR OPTIONS Yes
3.4 ENTER USERNAME Enter your phone no. here eg. 2437xxxx
3.5 ENTER PASSWORD Enter your password here.
3.6 Some other question will also be asked press yes for all the rest.
4. To connect type "pon dsl-provider"
5. To check if connection is on type "plog"


Small tip

If you are having a connection problem and feel that the connection could break and you want it to continously reconnect then try the following in a terminal

while true; do pon dsl-provider; sleep 1m; done

Where 1m stands for 1m . If you want to change delay you can type
xm for x minutes.
xs for x seconds.

Comments, clarification and corrections if any are welcome.