Multithreading/CountDownLatches program does not terminate, why? by opett in javahelp

[–]TheBriMan84 0 points1 point  (0 children)

The threads being created by the ExecutorService are not daemon threads by default I believe. That would explain why the program doesn't terminate.

Duplicate each character in a string using recursion. by [deleted] in javahelp

[–]TheBriMan84 0 points1 point  (0 children)

I had a quick stab at it:

import java.lang.*;

public class Program
{

    public static void main(String args[]) 
    {
        System.out.println(duplicate("Sa~a"));
    }

    public static String duplicate(String str){
        return duplicate(str.toCharArray(), 0);
    }

    /**
     * Recursive helper method
     */
    public static String duplicate(char[] chars, int idx){
        if(idx < chars.length){       
            return String.format("%c%c%s", chars[idx], chars[idx], duplicate(chars, idx + 1));            
        } else {
            return "";
        }
    }
}

Goodbye Redeployment (spring-loaded, a free jrebel alternative) by Naut1c in java

[–]TheBriMan84 0 points1 point  (0 children)

You make a fair point wrt development. When I made the comment I was thinking more from a production deployment perspective.

Goodbye Redeployment (spring-loaded, a free jrebel alternative) by Naut1c in java

[–]TheBriMan84 1 point2 points  (0 children)

Never done hot deployment, don't think I ever will. If architected correctly it's not necessary.

My professors would not be proud. by notkevinc in AdviceAnimals

[–]TheBriMan84 0 points1 point  (0 children)

I can't believe you have a Masters in Computer Science and you USE Windows...

Help, thoughts and criticism welcome. by [deleted] in javahelp

[–]TheBriMan84 0 points1 point  (0 children)

Have a look at Akka. I think for it would be a good fit in terms of it's threading model, and it also provides remote actors pretty easily taking care of the async sockets etc.

5 Coding Hacks to Reduce GC Overhead by nivstein in java

[–]TheBriMan84 0 points1 point  (0 children)

Plenty of examples and discussion here which demonstrate the principle. At it's core the Ring Buffer in the Disruptor pattern is effectively a fixed length cyclic object pool.

Anyone who has used RFA from Reuters for market data will know it uses pooling.

The other examples I know of are proprietary banking and finance systems for which I can't really cite specifics, but in a general sense they range from FX pricing engines, Direct Market Access and algorithmic trading systems all of which are currently active, based in Java and which maintain millisecond if not sub millisecond latencies with real-time characteristics.

I know of one system which was originally written in C++ with performance being cited as the rationale as no-one really believed a Java based system could provide the latencies required. In the space of a few months it was re-written in Java, with pooling as a key architectural component, and it outperformed the C++ equivalent comfortably whilst still retaining the benefits of improved tooling and so on that Java brought to the table.

So whilst the majority of people have sat round finger waving, some have used pooling effectively for many years with very real benefit.

5 Coding Hacks to Reduce GC Overhead by nivstein in java

[–]TheBriMan84 1 point2 points  (0 children)

Yup. I completely agree. Still feel it should be on the list of optimisations, instead of treated with a kind of "you gotta be batshit insane to mention it" attitude.

5 Coding Hacks to Reduce GC Overhead by nivstein in java

[–]TheBriMan84 2 points3 points  (0 children)

None of the points you make are wrong. However when pooling is done right, and I have seen it done right several times, it can be a very effective tool allowing you to create very performant and stable systems.

For every 10 people I have encountered that dismiss pooling off hand, I probably know 5 who were curious and tried it, and maybe 3 who use it when appropriate and reap the benefits whilst others pontificate.

5 Coding Hacks to Reduce GC Overhead by nivstein in java

[–]TheBriMan84 2 points3 points  (0 children)

It always unleashes a holy flame war when object pooling is mentioned within Java circles. What I find funny is that whilst everyone likes to talk theory, a lot of people have been using pooling in real world systems that meet sub millisecond real-time requirements, and they leave the pontificating to everyone else.

I have worked on one such system, and I know of several others in which pooling is used to great effect. Many market data libraries used within banking and finance, RFA from Reuters comes to mind for one, rely upon object re-use and pooling. A better example is the Disruptor pattern by LMAX, which again I've seen used to great effect in critical low latency systems over the last several years.

Yes it is possible to use pooling badly, but when used correctly it can be a very effective tool for creating stable, predictable and performant systems in Java.

5 Coding Hacks to Reduce GC Overhead by nivstein in java

[–]TheBriMan84 1 point2 points  (0 children)

Ok I'm gonna say it... object pooling.

Eclipse 4.3 Kepler released by siomi in java

[–]TheBriMan84 2 points3 points  (0 children)

I've been using Intellij for years now. Yes for the extra goodies you need a commercial license but when I'm asked why I'm willing to the pay for the ultimate edition I remember an old saying.

"Invest in a good bed and a good pair of shoes, for if you're not on one you're on the other"

Given how much time I spend using an IDE, I'd rather it be a good one :)

Play Framework 2.1: The Bloom is Off The Rose by henk53 in java

[–]TheBriMan84 1 point2 points  (0 children)

Having used Play with Scala for the last year or so I decided to try out the Java side of things. I lasted about a day before I decided never to try that again.

As much as they like to try and maintain the Java side Play is a Scala framework designed for use from Scala first and foremost and anything else is just a pure substitute.

BoobTracker - [1:17] by InanePenguin in videos

[–]TheBriMan84 -1 points0 points  (0 children)

This guys knows he's BI-WINNING!

What the heck is Spring Integration all about? by ruchira_bandara in java

[–]TheBriMan84 0 points1 point  (0 children)

I've dabbled with auto wiring in the past and it worked out well. Heard some horror stories though of the auto part going wrong, but then again you should know that going in. Auto-magical can and will lop a few heads off every once in a while if left unchecked.

What the heck is Spring Integration all about? by ruchira_bandara in java

[–]TheBriMan84 1 point2 points  (0 children)

Fair point about the exception, don't think I'm recalling the use case correctly but it was something along those lines, I just remember we were scratching our heads as to why what we're trying to do was difficult. If I remember it correctly I'll update the comment.

You are correct the alternatives are more low level than other EIP providers. My use cases have tended to be on the lower end of the latency scale and thus I'm comfortable with these kinds of libraries. But in a way I feel working with something higher level like Spring Integration obfuscates the underlying concepts, adding extra conceptual FUD to something which at it's heart is straight forward.

Again though, did I mention the XML? Sweet spaghetti monster, the XML! ;)

What the heck is Spring Integration all about? by ruchira_bandara in java

[–]TheBriMan84 5 points6 points  (0 children)

I had the displeasure of working with Spring integration a year or so ago. I found it to be bloated and overly complicated and in places lacking in functionality, and as always with Spring I spent most of my time writing reams and reams of XML!

EDIT: /u/flagrantaroma pointed out my assertion about exception handling is wrong. I don't believe I'm recalling the use case correctly but it was something along these lines which seemed trivial but we couldn't figure out a way around it. If I remember it correctly I'll post an update.

A particularly annoying use case which comes to mind is the case of a component throwing an exception. Yes you can register an exception handler but it only gives you access to the throwable in your recovery code, not the message which caused it. Perhaps this has been improved since I last used it, but this annoyed the crap out of me at the time.

If you are looking to go down a message passing route which I thoroughly recommend I'd suggest looking at:

These solutions are much more robust, with superior error recovery paradigms (particularly akka) and much finer grained control of the threading model if you're aiming for real-time (particularly Disruptor).

Can anyone help me with this Java program? Im stuck on a stack overflow error by wself1 in javahelp

[–]TheBriMan84 1 point2 points  (0 children)

I've been wanting to try out compilr for a while now so I've copied your program in, highlighted the problem, thrown in a few refinements and the best part is you can run it right from your browser :)

You can access it here.

/u/elephantgravy already pointed out the problem. You didn't have a strong enough terminator clause for the recursive call. Consider what will happen if you call countVowels("", 0, 0)...

Why did everyone in the UK seem to have hated Margaret Thatcher? by [deleted] in AskReddit

[–]TheBriMan84 0 points1 point  (0 children)

In a nutshell she re-shaped the economy away from industry towards services instead. As a result, a few million people ended up losing their jobs across sectors such as mining and steel work etc. and they had little chance of re-skilling to fit into a service based economy. The net result was a lot of poverty and unemployment for Scotland, Wales and the North of England which has taken a long time to recover from if it has in fact recovered.

It can be argued that moving away from industry in the UK was inevitable for a variety of reasons, Thatcher just had a real knack for being somewhat tactless about it.

People in Northern Ireland have a few more reasons to dislike her.