Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!

Ismail

Greenhorn
+ Follow
since May 16, 2002
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 Ismail

I have to stop the execution of a class which I cannot modify.
18 years ago
Hi,
I know that killing of threads with stop() method of Thread class is deprecated in JAVA. But still I need this for deliberately killing a thread because I don't have any database activities in my program.
Here is a sample program I wrote for killing threads. But I found that the program hangs several times during execution.
Can you identify what is the problem in this program.
Here is the class which starts a thread :
public class ThreadStopTest
{
public static void main(String args[])
{
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
SampleThread st = new SampleThread();
st.setPriority(Thread.MIN_PRIORITY);
st.start();
long starttime = System.currentTimeMillis();
try
{
Thread.currentThread().sleep(100);
}
catch (InterruptedException ie)
{
ie.printStackTrace();
}
System.out.println(" Time waited :: " + (System.currentTimeMillis() - starttime));
System.out.println("Thread started ");
st.stop();
System.out.println("Thread stop called");
System.out.println("Checking activity of thread :: " + st.isAlive());
}
}
Here is the class which is the thread.
public class SampleThread extends Thread
{
SampleThread()
{
}
public void run()
{
int i = 0;
infiniteloop:
while (true)
{
if (i == 1000)
break infiniteloop;
System.out.println("Current i is :: " + i);
i++;
System.out.println("This thread terminates when the count reaches 10000000");
}
}
}
It is very important that I should have a solution for this because we are using this in a project.

Thanks,
Ismail
18 years ago
Hi,
I know that killing of threads with stop() method of Thread class is deprecated in JAVA. But still I need this for deliberately killing a thread because I don't have any database activities in my program.
Here is a sample program I wrote for killing threads. But I found that the program hangs several times during execution.
Can you identify what is the problem in this program.
Here is the class which starts a thread :
public class ThreadStopTest
{
public static void main(String args[])
{
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
SampleThread st = new SampleThread();
st.setPriority(Thread.MIN_PRIORITY);
st.start();
long starttime = System.currentTimeMillis();

try
{
Thread.currentThread().sleep(100);
}
catch (InterruptedException ie)
{
ie.printStackTrace();
}
System.out.println(" Time waited :: " + (System.currentTimeMillis() - starttime));
System.out.println("Thread started ");
st.stop();
System.out.println("Thread stop called");
System.out.println("Checking activity of thread :: " + st.isAlive());
}
}
Here is the class which is the thread.
public class SampleThread extends Thread
{
SampleThread()
{
}

public void run()
{
int i = 0;
infiniteloop:
while (true)
{
if (i == 1000)
break infiniteloop;
System.out.println("Current i is :: " + i);
i++;
System.out.println("This thread terminates when the count reaches 10000000");
}
}
}
It is very important that I should have a solution for this because we are using this in a project.

Thanks,
Ismail
18 years ago
I hope you may use, URLConnection especially, for authentication purposes. See, Core Java, Vol 2 book, for how to implement this.
Finder methods are declared in interfaces. Interfaces cannot have static methods.
Even I have the same problem. xsl:copy-of is converting the entity refernces into strings. Also, I have one more issue, it is not converting ™ into the (tm) trade mark symbol as superscript properly, instead it gives ? as output.
The following XML String, when parsed and printed again, using Xerces, replaced the escape sequence ™ with ?. Why?
The ™ (browser is not displaying the entity reference as is. Please read of the ™ as #153 with & as prefix i.e., as &# 153; without space character in between) entity reference in the following XML :
<SELECTION_CODE SEL_CODE="055" SEL_CD_CATEGORY_ID="10737" SEL_CODE_DESC="™" PRODUCT_COUNT="6" ITEM_COUNT="17"/>

got replaced with ? :
<SELECTION_CODE ITEM_COUNT="17" PRODUCT_COUNT="6" SEL_CD_CATEGORY_ID="10737" SEL_CODE="055" SEL_CODE_DESC="?"/>

I would appreciate your help.
[ October 28, 2002: Message edited by: Ismail ]