Originally posted by Gunjan Malhotra:
Hi,
I seem to have forgot thread basics
In following program i have created 2 threads.
class extending Thread Class has two sunchronized methods ehere in one code in sec synchronized method ie callme2() calls callme1(). As per the output, it is possible..
Also,If a thread sleeps in a synchronized methos, other thread can enter into the same method. As per my knowledge so far it shuld not happen, but it is actually happening..
i think its time to open my books again
class threadtest
{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
{public SimpleThread(String str)
{super(str); }
public void run()
{callme1();
callme2();
}
void callme1()
{threadtest.print("111");
synchronized(this)
{threadtest.print("in Callme1 "+getName());
try { sleep(5000);
} catch (InterruptedException e) {}
threadtest.print(getName()+" getting out of Callme1");
}
}
synchronized void callme2()
{threadtest.print("in Callme2 "+getName());
callme1();
threadtest.print(getName()+" getting out of Callme2");
}
}
/* Output
>>>>>> in Callme1 A
>>>>>> in Callme1 B
>>>>>> 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
*/
Originally posted by suresh rg:
Hi
Suppose a query fetches some 20000 records from DB & the client displays the results just 10 records per page, How big is the resultset. In ASP we have a provision for fetching the results page by page to reduce the overhead on the server. Do we have anything in JDBC to send results page/page
Originally posted by Jaggi Kunal:
I have JDK1.4. But when I try to print the API using javap javax.sql.Connection I don’t get the output. What do we need to install for JDBC2.0?
Originally posted by Vishal Saxena:
hello,
Without it too, the driver/db info. can be read from a file - it need not be hard coded in the class.
With it too - the DataSource properties will be read from a file to bind it, the jndi info will again be read from a file for lookup.
regards,
Originally posted by Huzefa Zohaib:
Can I write the object to Database
I want to write the object in database can I do it by converting it to
set of bytes or strings or otherwise.
Originally posted by Manoj Bajpai:
we all know that preparedstatements improve performance due to precompiled sql statement.
eg
con = getConnection();
ps = con.prepareStatement("INSERT INTO...
...) VALUES(?,?,?,?,?)");
however, if a new instance of con is used each time, is there really an advantage. which means to
truly get the benefit i should make sure i am using the same connection, correct ???
thanks,