Win a copy of Head First Android this week in the Android forum!

suvasis mukherjee

Greenhorn
+ Follow
since Feb 22, 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 suvasis mukherjee

hi
Is there a short example to use jts in weblogic 8.1 env?
Thanks
suvasis
18 years ago
hi,
I am using weblogic8.1.
Where should I map EJB jndi in config.xml file?
Thanks.
suvasis
18 years ago
I followed the following step to get MS-SQL to work:
how to configure MS SQL server in jboss?
1. delete the hsql*-service.xml file in the C:\jboss\jboss-3.0.6_tomcat-4.1.18\server\default\deploy
directory.
2. copy the mssql-service.xml file from the C:\jboss\jboss-3.0.6_tomcat-4.1.18\docs\examples\jca directory
into C:\jboss\jboss-3.0.6_tomcat-4.1.18\server\default\deploy
3. change the C:\jboss\jboss-3.0.6_tomcat-4.1.18\server\default\config
a) standardjaws.xml
<jaws>
<datasource>java:/MSSQLDS</datasource>
<type-mapping>MS SQLSERVER2000</type-mapping>
<debug>false</debug>

b) standardjbosscmp-jdbc.xml files.
<defaults>
<datasource>java:/MSSQLDS</datasource>
<datasource-mapping>MS SQLSERVER2000</datasource-mapping>

4. in the mssql-service.xml following changes:
<attribute name="ManagedConnectionFactoryProperties">
<properties>
<config-property name="ConnectionURL" type="java.lang.String">jdbc:microsoft:sqlserver://68.165.1.253:1450;DatabaseName=CABIN</config-property>
<config-property name="DriverClass" type="java.lang.String">com.microsoft.jdbc.sqlserver.SQLServerDriver</config-property>
<!--set these only if you want only default logins, not through JAAS-->
<config-property name="UserName" type="java.lang.String">mina</config-property>
<config-property name="Password" type="java.lang.String">sm4321</config-property>
</properties>
</attribute>
......
and also
<depends optional-attribute-name="ManagedConnectionPool">
<!--embedded mbean-->
<mbean code="org.jboss.resource.connectionmanager.JBossManagedConnectionPool" name="jboss.jca:service=XaTxPool,name=MSSQLDS">

5. in the C:\jboss\jboss-3.0.6_tomcat-4.1.18\server\default\config dir
change the login-config.xml file
<application-policy name = "MSSQLDbRealm">
<authentication>
<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
<module-option name = "principal">sa</module-option>
<module-option name = "userName">user</module-option>
<module-option name = "password">passwd</module-option>
<module-option name = "managedConnectionFactoryName">jboss.jca:service=XaTxCM,name=MSSQLDS</module-option>
</login-module>
</authentication>
</application-policy>
18 years ago
hi
huang zhiguo solution is better because of the following reasons:
1. When you subclass Thread as in your case, the Thread object is just ab object that happens to point to the actual thread(a kernel, structure etc). Once a thread exits("stopped"), it's gone. It can not be restarted. Moreover, your intention is not to change nature of thread, so don't subclass it.
2. Whereas a Runnable may be used with as many threads as you like. this is a better solution.
Also, instead of sych the whole thread, you can sych only the loop portion i.e

Object o = new Object();
synchronized(o) {
for (int i=0; i< 5; i++) {
System.out.print(c);
}
}
suvasis

Originally posted by ShihChao Lin:
Hi:
Can anyone tell me why the synchronized for following code does not work?
public class SyncTest extends Thread{
StringBuffer letter = new StringBuffer("A");
private synchronized void printChar() {
char c;
c = letter.charAt(0);
for (int i=0; i< 5; i++) {
System.out.print(c);
}
System.out.println();
c++;
letter.setCharAt(0, c);
}
public void run(){
printChar();
}
public static void main(String[] args) {
SyncTest t1 = new SyncTest();
SyncTest t2 = new SyncTest();
t1.start();
t2.start();
}
}
I was hoping the output will be
AAAAA
BBBBB
But the result was
AAAAAAAAAA
Thanks for your help

hi,
I am not clear, but if you looking to stop a thread, can you try join().
another suggestion:
say:
public MyRunnable implements Runnable {
public void run() {
do_something();
}
}
Thread t = new Thread(new MyRunnable());
t.start()
The reason is:
You are probably not changing the nature of thread, so don't subclass it. In java Thread object is just an object that happens to have pointer to the actual thread (i mean stack, kernel, etc). Once a thread is exited, it's gone. It is not "restartable". Hence, runnable is better, you can have as many threads as you want....
so view Threads as the engines for getting work done, while the Runnable is the work to be done.

Originally posted by Roy Huang:
[QB]I have currently the problem of using a timer thread to limit the HTTP connection.
This is a timer class extending the Thread class, In a synchronized run method, two counters will be compared for time out, the exception will be thrown and the other HTTP application thread will be stopped.
The problem in my case is that:
The HTTP application and this timer thread is one target in the anttask, if more targets are executed sequentially in this ant task, the timer thread always blocks other application--- since when the HTTP application is finished, it can not stop the timer thread correctly. (Here I use timerthread = null, as Java.Sun.com suggest not use the stop() method-> to stop the thread.)
so the exact http application is not blocked by this thread but some others will be affected..
QUOTE]