Help coderanch get a
new server
by contributing to the fundraiser

Sidharth Pallai

Ranch Hand
+ Follow
since Apr 21, 2008
Merit badge: grant badges
For More
Bangalore
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Sidharth Pallai

Stefan Evans wrote:
However it won't guarantee anything about how many threads can retrieve a reference from the Map.  You would need some sort of locking/semaphore logic for that.



Hi Evans,

Does it mean that 2 threads can get the same connection object upon synchronizedMap.get(String Key) ?
Java API reads all the methods of synchronizedMap are mutex as below:


public V get(Object key) {
           synchronized (mutex) {return m.get(key);}

}
7 years ago
Am using a synchronized HashMap to keep live connections for reuse. For some reason i find more than one thread get access to a connection object from the map (conns.get) and get in to a BLOCKED state as per below thread dump. Here first thread "A-worker-pool-40-thread-1" get a lock on "0x00000007518b7020" and then "A-worker-pool-40-thread-5" and "A-worker-pool-40-thread-6" wait for the same lock "0x00000007518b7020" to get released. Am i misinterpreting something here? Please suggest.

"A-worker-pool-40-thread-1" prio=10 tid=0x00007fa27800e000 nid=0xd6b0 runnable [0x00007f21dffc8000]
at com.xyz.connection.getConnection(Connection.java)
- locked <0x00000007518b7020> (a com.xyz.Connection)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
       at java.lang.Thread.run(Thread.java:745)

"A-worker-pool-40-thread-5" prio=10 tid=0x00007fa498001800 nid=0xd6af waiting for monitor entry [0x00007f225ffca000]
java.lang.Thread.State: BLOCKED (on object monitor)
at com.xyz.connection.getConnection(Connection.java)
- waiting to lock <0x00000007518b7020> (a com.xyz.Connection)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
       at java.lang.Thread.run(Thread.java:745)

"A-worker-pool-40-thread-6"  prio=10 tid=0x00007fa9d800e800 nid=0xd6ae waiting for monitor entry [0x00007f22dffcb000]
java.lang.Thread.State: BLOCKED (on object monitor)
at com.xyz.connection.getConnection(Connection.java)
- waiting to lock <0x00000007518b7020> (a com.xyz.Connection)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
       at java.lang.Thread.run(Thread.java:745)

7 years ago
It took me much time to identify the space after the string "com.aaa.TelnetMgr" in the the array declared in the interface, for which it was creating two instances for the same logger. Sorry to take your valuable time folks.
12 years ago
Hi

The below code creates two instances of Logger, couldnt figure out why.

----------


Logger with static modifier, should get initialized once when class is loaded, but it gets two instance instead of one. Removing the static modifier solves my problem.What is the relevance that it creates two with a static modifier.
12 years ago

Sidharth Pallai wrote:If you just invoke run() directly, it's executed on the calling thread, just like any other method call. A new call stack never gets created.Thread.start() is required to actually create a new thread/new call stack so that the runnable's run method is executed in parallel.start() enable the Thread to be controlled in states.
start() is not invoked for the main method thread or "system" or group threads created/set up by the VM. Any new functionality added to this method in the future may have to also be added to the VM.

Hi Stephen,

Thanks for the explanation.i would like to how could i decide if the objects are no longer needed or they need to be retrieved from the database again.I mean when could i decide that i dont need them anymore and how , once they are presented to the user in listing table of HTML. Or when i could take the decision to save the references.

Take for example , once i've the List of <Person> from the database, i set it to request attribute for display in the listing JSP. So, once the request forwards the list to the JSP and the JSP draws all the listing elements. So once i set it to request attribute, is that the next line i would do something like this ...

request.setAttribute("personsList",list);
if(list!=null)
list=null;
13 years ago
Hello,

I would like to know , how would we GC the domain objects / value objects that are retrived from the database to be displayed in JSP. How/when we can make sure that those objects , after they are done with the display will be GC'd.

The domain objects are large in number that are retreived from the database. Say for example , 1000 Person objects or 1000 rows of Person data. or 1000 Persons.
13 years ago
Hi,

Flex is one option. While DOJO with xml/json/ajax , DHTML. Dojo has grown very well in market incorporating almost all widgets that meets the demands for critical verticles (HealthCare/StockMarket/NMS-EMS... and lot more).

Very easy to learn and use. Forum is available for help.
13 years ago
Spring do provide IOC through Dependency Injection either with Setter Injection or Constructor Injection, with a aim to avoid TightCoupling and enforce LooseCoupling. In tight coupling, one object is heavily dependent on other object like as below.



Lets try attempt to reduce the impact of tight coupled Travel & Car object


Now Spring did it through XML bean configurations .... as below



spring.xml Configuration :


I can define any vehcile in the xml , ie a Train/Aeroplane/Cruise/Horse/Camel............
13 years ago
Thats appropriate, But EJB is nowadays a tiring job for any developer to code specifc segments of functionalities (Transactions/Security/Concurreny/JNDI Lookup) and at the same maintain better design approach. which is a cumbersome. So, todays trends provides Spring Framework, that comes up all-in-one plate to pick/use features which you need. Services are already in place , we just need to provide our implementations, and at the same mainatin design protocols like coupling throught DI/IOC , AOP , WebMVC, DAO integration with ORM , integration with struts/velocity/jsf... and lots more. !! Go through Spring Framework concepts , it will fetch you how to place ut problem state into designated places and make them feel/work in a better fashion , i mean in OOP's way!
13 years ago
The reason JSP came into existence, is to separate the "View" from "Business Logic / Controller". Servlets are meant for Java programmers and JSP is looked as cup of coffee for WEB/GUI Developers. Its the job of a java developer who makes custom tags available for the GUI/Web developers. Gone are the days, where we used to embed HTML tags into servlets. Take for an instance , if in future we need to change the GUI that requires the change in Servlets ....compilation etc etc... which would create catastrophic changes in software systems!!!...........

..........Take for one increasing challenge of today, where we need our system to be ported to PDA's & other commercial appliances / applications. So with the servlets we gonna code for PDA's , appliances , HTML , etc etc ...... OMG
13 years ago
My application has around 1800 JSP's, which is intended to be migrated to a different version, where tags/strings refrered in JSP's has to be replaced with prefrered tags/strings.

Am planning to go for a java application which will gurantee the find and replace prefered strings/text based on user serach criteria.

I just want to know how to make sure that all pages with "some" text get replaced , or the approach to create a separate application would be of any usefulness.

If any one could suggest any other approach or idea to arrive at such a solution, would of great usefullness for me.

14 years ago
JSP
Sorry Folks,

Since there was similar model class for Table, i was looking out for Tree.
14 years ago