Wednesday, January 31, 2007

Multithreading ThreadPool class replacement

Some very useful code for wanting a ThreadPool that actually multithreads (as .Net's builtin ThreadPool object only runs one thread at a time):


namespace Wiegand
{
    public class ThreadPool
    {
        private System.Collections.Queue _queue = new System.Collections.Queue();

        public long QueueLength()
        {
            lock (this._queue) { return this._queue.Count; }
        }
        public Object Dequeue()
        {
            lock (this._queue) { return this._queue.Dequeue(); }
        }
        public void Enqueue(Object value)
        {
            lock (this._queue) { _queue.Enqueue(value); }
        }

        public void RunThreads(int threadCount, System.Threading.ParameterizedThreadStart pts)
        {
            // now, start the threads
            // since threadpool only actually runs one thread at a time, it is not ideal for this situation
            System.Collections.Generic.List threads = new List(threadCount);
            for (int i = 1; i <= threadCount; i++)
            {
                Thread thread = new Thread(pts);
                threads.Add(thread);
                thread.Start();
            }

            foreach (System.Threading.Thread thread in threads)
            {
                thread.Join(); // wait for each to finish
            }
            // done!
        }
        public void RunThreads(int threadCount, System.Threading.ThreadStart pts)
        {
            // now, start the threads
            // since threadpool only actually runs one thread at a time, it is not ideal for this situation
            System.Collections.Generic.List threads = new List(threadCount);
            for (int i = 1; i <= threadCount; i++)
            {
                Thread thread = new Thread(pts);
                threads.Add(thread);
                thread.Start();
            }

            foreach (System.Threading.Thread thread in threads)
            {
                thread.Join(); // wait for each to finish
            }
            // done!
        }
    }
}

Sunday, January 28, 2007

My newest quote

My newest quote:
One thing I've learned from Disney: there's a HUGE difference between good magic and bad magic. Good magic always comes with good clothes. Bad magic never does. So the next time you're being transformed from a mermaid to a human, check your dress afterwards!

Tuesday, January 16, 2007

Today

Well, I got a lot done at work today - got the UI about half way integrated with the business logic/data access logic. Also pulled those two things out into a separate library (made making the service-which-became-a-scheduled-task easier, and will make writing those unit tests that I'll have time for next century easier). Yes, you read that right, there's not really time for proper unit tests. But, I may have time soon: we're hiring an intern. Wow, I never realized how little they pay those guys. Hehe. Anyways, he'll be doing DBA-like stuff. I get to teach him how to do OLAP (yeah, I'm such an expert, but at least I do know some stuff), and how to properly indent SQL (well, at least from my POV), and sprocs in MySql (which is the worst implementation known to man - why, for the love of {insert divine entity's name here} did you NOT use @ for the parameter variable names!?). I hope that we're able to get him in soon so that I can teach him the current setup, get his opinions on it, and get him to start writing some queries/reports. I think we're doing pretty well on the timeline - I'm actually about a day ahead of where I wanted to be. We ( and I) went to CompUSA today to get Yoshi's Island 2 for the DS for her belated Chanukah present. So maybe in a week or two she'll get her belated Christmas present. :)

Male lactation

A video on male lactation

Just thought I'd share.

Sunday, January 14, 2007

Daily interaction with religion

Recently, and I were discussing religion, and I mentioned that Judaism is constantly in one's life: one has to keep kosher was the example I gave (although there are so many more, the laws of niddah (not touching those who are in an "impure" state), daily Torah study, etc.). I also mentioned that these laws have an effect, intended or not, of keeping Jews separate from non-Jews. He said that Mormonism, on the other hand, doesn't really have anything that would really separate him, or try to separate him from others. After some thinking about this, and recognizing that I am NOT attacking either religion, or saying one is better than the other, does it make sense (to us humans) to have our religion constantly "in the way"? To a point, having laws that cover every situation, and that dictate the correct reaction to all situations, would be very stifling (well, there IS a reason I'm not an Orthodox Jew). But would I want Judaism to be something that I don't think of on a daily basis (OK, there are certainly days when I just chug through the day and so it really doesn't bubble up into my conscious much..)? If I were to take out kashrut (keeping kosher of some form) and all of the other parts of Judaism that are observed daily, and are rather visible, would it matter? Would it still be Judaism? Would it be as good for me (would it benefit me to the same extent, either spiritually or in other ways)? How would having a Mormonism that had more rules, or that was more public, more obvious change things? (Hey, we've already cornered the market on kippot/yarmulkes, but maybe y'all can wear head bands, or the same ring, or dye your hair green, or something. :) Also what was interesting to me is that Mormonism is apparently the only Christian church that is NOT "one-true-way"ish. Of course they think their way is the most direct. But that they don't think that other ways are false (well, i'm sure some are from their POV), but that not all are automatically false, that is kinda cool. Maybe Christianity is maturing (we older religions don't seem to have this problem, but the younger ones generally do, at least that's how I see it). Not to imply that Christianity is immature! Just that it's aging, mellowing, getting to know the neighbors and seeing that we all share more than one might think. Hmm... I definitely see that I'm going to be looking at my own religion more now that I'm interacting with someone from another faith, who has no problem (so far!) discussing religion with me. Which is probably a good thing.

Recent stuff

Yesterday: So, , and I went over to a couple friends' house yesterday. We guys had fun, watched the kiddos and discussed lots of stuff. Quite a bit about Mormonism (they're Mormon, I'm converting from nothingism to Judaism). Now, I recall reading up about Mormonism before, back when a family member was thinking of joining (not to mention, I love studying other religion's beliefs). But I've forgotten quite a bit, and honestly, I never mind learning more. So I'm reading up on it, and the various sects, and I found out that just like Judaism, Mormonism has an "Orthodox", "Conservative", "Reform" and "Reconstructionist" split. To me this is interesting (almost funny, but not quite). [source]. Anyways, I may check out a book or two about it to learn more. And of course discuss it with more (assuming he's OK with that).

Yesterday dinner: All of us (,, myself, , Tiny and ) went to Yak and Yeti, a wonderful Nepalese/North Indian buffet/restaurant. The food was great! The lamb was good, the various chickens were good. I couldn't spell half of the things I ate there and liked, but if you happen to be near enough to Broomfield, you might try it.

Work: I got the database, data access layer and business logic layer done. Well, mostly that is. I've still got to create a PropertyComps structure (not even going to call it a class), a function to call them up, and a MySql ASP.Net membership provider (although I'm really reconsidering using that, I think it'll depend on how the UI is supposed to work). Speaking of the UI, I should be getting the web design from them Monday, so I will probably review it, make my test pages use the proper UI, and create those simple pages that I hadn't yet because they were so simple. I'm on-target. Oh, and I think the pay side of things will come out alright in the end: Signal was paying me a certain amount, these guys almost the exact same amount. Signal was putting in an extra $500 a month to help defray medical insurance. Well, I was paying $800/month for a family on that. I can get private insurance with similar benefits (a little higher on the deductible, but office visits are just $25, and pregnancy isn't covered) for $300/month, which is kinda what I was paying out of paycheck before. So, we'll see with the first full paycheck, but I think things'll be OK. I get a REALLY nice work laptop too (been using my personal Celeron 1.8GHz for awhile now...): 3.0GHz Intel Core 2 Duo, 1.5 GB ram, 120GB hard drive. It will kick butt. I could (and probably will) totally virtualize the devel web server and devel db server (to help test the configuration). I get it (in theory) on Thursday. Fun fun fun!

The future: Well, we've got a friend who's almost certainly going to move in, at least on a trial basis. Got to make room for them (her and her 1yr old kid). That means clearing out the baby room (which we don't use except to change , and he's getting big enough to do that on the floor now), putting that stuff in either the inlaws' basement or our garage. It also means clearing out the garage of all of the junk. Which means I need to get a dumpster out here. Gotta remember that, maybe for end of month.. Need to find winning lottery/PowerBall ticket (yeah, that's going to happen, but if it does, you'all will be the ... er... 10th or so to know). My brother's finally getting married, although I don't know how much of a ceremony they'll have. It'll be July 4th, though, so it'll be easy to remember. I'm looking forward to all of this snow melting. We got the 4th, yes 4th, batch of snow since Friday. Driving this morning was not fun, let me tell you.

Well, I'll probably sign off now. Need to finish eating the macaroni and cheese. Oh, one last thing: We got the Avatar: The last airbenter DVD (1st season, all episodes) box set yesterday, so we've been watching them a lot recently.

Sunday, January 07, 2007

School

Reference: Denver Post, today Okay, I think these are great ideas. Particularly the one about testing students at the end of 10th grade, and from there determining if they would be better off going to a trade school/community college or staying in high school to eventually go to university/college. It's been 10 years, but I clearly recall students who really were in school because they had to, either because of parents or to get the diploma. PLENTY of students I went to school with never went to university/college, and ended up getting retail, construction, or other blue collar jobs. Allowing them out early would remove some of the students who cause problems now in school, AND give them a career path earlier that really should fit them better. And that's not to say that they can't go to college, just that they would have the option of short-circuiting to trade school/community college. Germany has a similar setup - you go to a trade school, finish normal high school, or go to a university-prep high school. I think it makes a lot of sense, and hope to see it in Colorado someday.