Originally posted by Nitesh Kant:
If i see a system that creates 130 threads to do some work i will make sure that it never gets into production.
Increasing the number of threads like that will not increase performance. Infact it will decrease it because of thread scheduling overheads. In this sort of a scenario your OS will only be busy swapping threads and before the thread can start work it will be swapped out to give the cpu to a different thread.
My suggestion is to use a threadpool. You have it readily available in jdk5 in the concurrent package. A backport of the same is also available for prior jdk 5. (just google for java backport concurrent)
Originally posted by Arjun Reddy:
Hi,
Do runtime exceptions need a try-catch blocks at all? Coz for ArithmeticException(Runtime Exception), even tho I did not put it in the try catch blocks, I was able to compile the code properly(It gave me an error at runtime.Even tho I put em in the try-catch, it still gives me an error at runtime only). But for SqlException(Compile time exception), if I don't have a try-catch blocks, It's giving me a compile time error.
Thanks.
[ June 26, 2008: Message edited by: Arjun Reddy ]
Originally posted by Seamus Minogue:
Deepa,
Have you tried stepping through the code yet?
The problem is this:
arr[i] = 0;
The way this for next works is for each iteration "i" will BE the next value in the array. Not the index of the next item in the array.
So stepping through it:
Iteration 1:
i = 1
set arr[1] = 0
arr = 1,0,3,4
Iteration 2:
i = 0
set arr[0] = 0
arr = 0,0,3,4
Iteration 3:
i = 3
set arr[3] = 0
arr = 0,0,3,0
Then you print them correctly giving you 0 0 3 0
:-)
Originally posted by Ramesh Kumar Swarnkar:
Hi Paul,
= No.
Sorry, if my question gives that impression.May be would have been more specific.
But, from above posts I come to a conclusion that:
if a method is 'static-synchronized', then to work on this method, one has to acquire Class Lock.
But, if the method is 'synchronized', then to work this method, one has to acquire Object Lock. And this implies to 'synchronized block' also.
Originally posted by Ramesh Kumar Swarnkar:
Hi Friends,
Need to know if a class (say class A) has two 'synchronized' methods, then is it possible to access each of these 'synchronized' methods by two separate object(say instance of class B and class C) ?
As per theory in java:
Every Class has a Lock.
Every Instance has a Lock.
Every Object has a Lock. (am not sure about the instance lock and object lock; whether they are same or different !? ).
Anyway, does this theory mean:
to work on any synchronize method an object need to acquire the lock of class(?) OR object/instance(?).
Can anybody please elaborate it.
thanks in advance !!
[ June 22, 2008: Message edited by: Ramesh Kumar Swarnkar ]
Originally posted by Avi Sridhar:
Thanks everyone for your thoughts. it really helped.
I am going to use this instead
and we will get 60 chars there.
Originally posted by GUNA RANJAN:
Thank You all the way which i worked is that correct ! if not denote my mistakes !
Swapping three variable without using temp variable
a = 2 b = 1 c = 3
a = a+b+c = 6
b = a -b-c = 2
c = a -b- c = 1
a = a-b-c = 3
After swaping
a = 3 ; b = 2 ; c = 1
Originally posted by Sravan Patti:
Hi,
I wanted to whether the use of variables in an interface is good practice or not. This question was asked in one of my interview.
Can also explain me the reason if it is NOT a good practice??
Thanks
Originally posted by Prabhat Gupta:
As i per my knowledge this is not DUPLICATE posting.
I know that the string that i am using it not valid one . But,the problem is when your are browsing some file in Windows OS , you will get that INVALID java string. Before processing i have to convert it as "C:\\Documents and Settings\\prabhat_kumar04\\Desktop\\Prabhat\\System.txt" or
"C:/Documents and Settings/prabhat_kumar04/Desktop/Prabhat/System.txt"
But the problem remains same that you are getting the inavlid String as input. So, what should i do now??
Originally posted by Muni Sammy:
Most of Indian Service based companies are keeping Notice period as Three months, do you think is this a loyal .... Eventhough if you don't have any dependency you have to be their for 3 months ....
I learned in America most of company have a one day Notice ....then why 3 months here ...
Originally posted by JIGAR THAKOR:
Here I am getting the data as I posted earlier.
This is not JDBC or query related question.
I want to achieve groupism of user_ids by server_ids.
key = server_id
values stored in list = user_id.
Please post it on the General Java - Difficult