Balbhadra Singh

Greenhorn
+ Follow
since Oct 14, 2003
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 Balbhadra Singh

Have you included scenarios and questions to explain key PM areas properly? I have seen that Scope, Time and Cost areas are quite confusing if person is not managing these areas already.
In my previuos code data object was not shared across threads. Now code works fine.

class DataClass {

void callme1() {

synchronized(this) { // 1
ThreadTest2.print("in Callme1 "+Thread.currentThread().getName());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}

ThreadTest2.print(Thread.currentThread().getName()+" getting out of Callme1");
}
}

synchronized void callme2() {
ThreadTest2.print("in Callme2 "+Thread.currentThread().getName());
callme1();
ThreadTest2.print(Thread.currentThread().getName()+" getting out of Callme2");
}

}

class ThreadTest2 {


static void print(String message) {
System.out.println(">>>>>> "+message);
}
public static void main(String[] args) {
DataClass data = new DataClass();
new SimpleThread("A", data).start();
new SimpleThread("B", data).start();
}
}
// **************************************************
class SimpleThread extends Thread {

DataClass o = null;


public SimpleThread(String str, DataClass o) {
super(str);
this.o = o;
}

public void run() {
synchronized(o) {
System.out.println("in run "+Thread.currentThread().getName());
o.callme1();
o.callme2();
}
}


}


in run A
>>>>>> in Callme1 A
>>>>>> A getting out of Callme1
>>>>>> in Callme2 A
>>>>>> in Callme1 A
>>>>>> A getting out of Callme1
>>>>>> A getting out of Callme2
in run B
>>>>>> in Callme1 B
>>>>>> B getting out of Callme1
>>>>>> in Callme2 B
>>>>>> in Callme1 B
>>>>>> B getting out of Callme1
>>>>>> B getting out of Callme2
Hi Gilbert,
Here is the formatted code.

class DataClass {

void callme1() {

synchronized(this) { // 1
ThreadTest2.print("in Callme1 "+Thread.currentThread().getName());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}

ThreadTest2.print(Thread.currentThread().getName()+" getting out of Callme1");
}
}

synchronized void callme2() {
ThreadTest2.print("in Callme2 "+Thread.currentThread().getName());
callme1();
ThreadTest2.print(Thread.currentThread().getName()+" getting out of Callme2");
}

}

class ThreadTest2 {

static void print(String message) {
System.out.println(">>>>>> "+message);
}
public static void main(String[] args) {
new SimpleThread("A").start();
new SimpleThread("B").start();
}
}
// **************************************************
class SimpleThread extends Thread {

DataClass data = new DataClass();

public SimpleThread(String str) {
super(str);
}

public void run() {
System.out.println("in run "+Thread.currentThread().getName());
data.callme1();
data.callme2();
}


}


/* Output
in run A
>>>>>> in Callme1 A
in run B
>>>>>> in Callme1 B //2
>>>>>> A getting out of Callme1
>>>>>> in Callme2 A
>>>>>> in Callme1 A
>>>>>> B getting out of Callme1
>>>>>> in Callme2 B
>>>>>> in Callme1 B
>>>>>> A getting out of Callme1
>>>>>> A getting out of Callme2
>>>>>> B getting out of Callme1
>>>>>> B getting out of Callme2
*/

I expected that when thread A is already holding the lock for data object (at line 1) there shouldn't be line 2 in the output.

When thread A goes for sleep it doesn't leave lock but takes it along with it. Then why is line 2 in the out put?

Thanks in advance.
Hi,
Can someone throw some light on the behaviour of class/object level monitor in java?

Does one takes precedence over other?

What happens when, class has both synchronized instance methods and synchronized static methods? Does calling thread has to acquire both class/object locks?

I would welcome a detailed explaination.

Thanks in advance,
Balbhadra
Hi,
I am confused the thread behaviour i am getting.
Scenario is like this ..
I am starting 2 threads one will read from the databse (using stored procedure).Both thread start and then once control comes to second thread which, is doing SP processing, it blocks the CPU (i.e control doesn't go back to thread 1). Is it because of socket issue?
Regards,
Hi Nassar,
I am using pjx.jar api to read pdf document. My aim is to get the "object structure" of the pdf document.
When i try to read pdf files, i get exceptions like ...
while reading pdf file1
com.etymon.pj.exception.PdfFormatException: Token " " not recognized.
at com.etymon.pj.StreamParser.processToken(StreamParser.java:958)
at com.etymon.pj.StreamParser.parse(StreamParser.java:22)
at GetPDFInfo.main(GetPDFInfo.java:35)
-------------------------------------------------------------
while reading pdf file 2
com.etymon.pj.exception.PdfFormatException: Token "%!PS-AdobeFont-1.1:" not recognized.
at com.etymon.pj.StreamParser.processToken(StreamParser.java:958)
at com.etymon.pj.StreamParser.parse(StreamParser.java:22)
at GetPDFInfo.main(GetPDFInfo.java:35)
-------------------------------------------------------------
while reading pdf file 3
com.etymon.pj.exception.PdfFormatException: Token "??? ?Adobe d? ?? C " not
recognized.
at com.etymon.pj.StreamParser.processToken(StreamParser.java:958)
at com.etymon.pj.StreamParser.parse(StreamParser.java:22)
at GetPDFInfo.main(GetPDFInfo.java:101)

Can you please tell me, what is the reason for errors?
The error is caused because of following line ..
Vector myvec = sp.parse( myPjStream );
This line appears in this block of code ..
StreamParser sp = new StreamParser();
PjStream myPjStream = ( ( PjStream ) obj ).flateDecompress();
Vector myvec = sp.parse( myPjStream );
for ( int j = 0 ; j < myvec.size() ; j++ ) {
if ( myvec.get( j ) instanceof XTj ) {
PjString myPjString = ( ( XTj ) myvec.get( j ) ).getText();
System.out.println ( myPjString.getString() );
}
}

Regards,
Balbhadra
18 years ago
Hi Venkatesh,
Just forgot about 'mock exam' in your question. Ya i took all the free mock exams available on the net (some of their answers were wrong, you have to verify your wrong answers) . Allan & Bambara also has one mock exam in the CD.
Regards,
Hi Venkatesh ,
I didn't get a chance to lay my hands on Cade's book, so comaparing Allan & Bambara with it will be difficult for me. Overall Allan & Bambara is satisfactory ( it covers things in much details ).
Hi Weerawit,
There were 3-4 questions on ejb. They are not so difficult (because i had been into ejb for close to 1.5 yrs now, for a beginner they might seem difficult).
Regards,
Hi,
Sun is offerring 20% odd on SCEA, contact SUN St.Marks Road center. These vouchers will be valid till oct 2004.
Regards,
Hi venkatesh ,
I referred J2ee study guide by Allan & Bambara (as indian edition of Mark Cade was not available). Besides, notes posted on scea_prep group helped a lot.
I prepared for about 3 months, initially 1-1.5 hrs a day and during last 15 days 2-3 hrs a day.
Regards,
Hi,
Today i passed scea ( part 1) with 89 %. Preparing for this exam was a learning experience. Thanks to this forums participants, for providing valuable information.
Regards,
Hi,
I guess class diagram would just show classe not objects. In a sequence i would show all the classes which, participate in execution of a use case.
Regards,
Balbhadra
Hi,
Can some one give me some info on prometric centers for "SCEA" in bangalore? I tried at 2-3 places but, they offer this exam.
Thanks in advance,
Regards,
Balbhadra