Is it a good practise store Thread in the Hashmap? [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I create a Hashmap xxx
store all Thread inside Hasmap
when Thread finish , will remove it
is it a good practise?
Here is my code : https://gist.github.com/extralam/756484718c9e0cd57ddb

The right way, since Java5, is the use of the ThreadPoolExecutor.

Related

How to sort a list lexicographical? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a list that I made with a type I created of . I want to sort it in lexicographical order. I have seen the compareTo in Java, am I supposed to use this? I'm not sure how to put it into the lexographical format from a list? Can anyone show me an example? I have seen many examples, but I am not sure how to do it from a list.
Just use implement the Comparable<Type> in your own Type class and implement the compareTo method to match the lexicographical order. Than just call Collections.sort(yourlistOfTypes).

How to implement an already well implemented module(like stack) in java using a linked list [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm trying to implement an stack using a linked list in Java, But I'm not sure which methods I have to implement(stack is a simple example here), How can I somehow get the methods and then extend my linked list class to implement my own class of stack
I know that somehow I have to use some kind of interface but it would be a great help if someone could guide me here.
A stack at its simplest just has Push() and Pop(). They map directly to the LinkedList methods push and pop already present!
So in order to implement a stack on top of a linked list you need to do....nothing :)

How to make a Java program that will interrupt a thread.sleep() if the mouse is clikced? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a Thread.sleep(100) line in my program. I want to interrupt the Thread.sleep if the mouse is clicked. What code would I write to do that?
Basically - don't. This is one of the reasons why Thread.sleep is discouraged. You should change it to a BlockingQueue.poll
// Thread.sleep(100);
blockingQueue.poll(100, TimeUnit.MILLISECONDS);
now you can stop the pause by pushing something into the blockingqueue at the other end.
You may even discover that you can increase the timeout too.

How to convert string to arary[][] in Java [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have below string which I get from an xml file.
<product>
<aa>1367</aa>
<ac>133787</ac>
<db>13345</db>
<ce>133</ce>
<er>135</er>
<et>130</et>
<ef>14</ef>
</product>
How do I convert it to an two dimension array like
product[][]={{"aa", "1367"},{"ac","133787"}, {"db","13345"}....}
I only want to use string function and loop.
I think the best way is to use an available XML parser.
In this thread: Best XML parser for Java you'll probably find which one is the best to use

How to create a suggestion box [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I was developing an java swing application to add view and modify the list of medicines.While adding the medicines it should show the list from the database(like google search box).For example if we press "p" it should show 'paracetamol' from the database.
You should implement a change listener on the text input box, when the text is changed, run a query to the database with the contents of the input box.

Categories

Resources