|
I'll try changing it to a fixed thread pool. Ultimately I would like it to be unbounded, and I'm really hoping that changing it will be somewhat revealing. Edit: Ah-ha! Actually I think I know what the problem is. You're right about the callback thing. This is a group (school) project where not all members of the group are really at the same level. I forgot... earlier on in the project I decided to model the thing using callbacks, and they`re all in place. However, these callbacks are not currently executed asynchronously from anyone else's side of things. Guess what I'll be doing today. Colonel Taint fucked around with this message at 18:00 on May 9, 2010 |
# ? May 9, 2010 17:43 |
|
|
# ? May 11, 2024 12:03 |
|
Psychorider posted:You should post the rest of the function so we can see why it doesn't work. The only thing I can think of is that you may close too many brackets and you end up outside the loop. I checked that. If I just change it to a plain for loop that works its way through the ArrayList it works fine. Bah.
|
# ? May 10, 2010 05:04 |
|
HondaCivet posted:I checked that. If I just change it to a plain for loop that works its way through the ArrayList it works fine. Bah. Is that definitely the only thing you changed?
|
# ? May 10, 2010 05:19 |
|
Jonnty posted:Is that definitely the only thing you changed? Yeah, you should probably show us the entire loop so that we can help. Your original sample wasn't enough to figure out the issue.
|
# ? May 10, 2010 05:30 |
|
rawstorm posted:Wow, this is really weird. I had Firefox open, and then I opened the program and it was running fine. Then I opened a new blank tab in Firefox and the program kept running fine. Then I went to https://www.cnn.com in the new tab, switched quickly back to my program, and it ran at normal speed for about 2 seconds and then suddenly started going really fast. What the hell is going on !?
|
# ? May 10, 2010 07:11 |
|
geeves posted:Any collection should do.. have you tried using <logic:present> to see if it's been loaded / available? Are you able to access the Collection with JSP instead of struts tags? Also, just a quick check - you are including the logic taglib, right? That last one has lead me to many headaches over time. ty, got it working now, something was going wrong in the controller part, making it just return a new collection instead of the one from the model
|
# ? May 10, 2010 09:30 |
|
Buster fucked around with this message at 05:45 on May 13, 2010 |
# ? May 10, 2010 19:41 |
|
Buster posted:I'm trying to remove the code repetition in Entry<E>'s add method, but I don't know why it doesn't work. Looking at the debugger, it seems that the changes I'm making to 'child' in recursiveTreeBuild() aren't affecting the actual child I passed in. Is there any explanation for this? I commented out the code that works. The reason it isn't working is that when you pass in child to the method, you're actually making a copy of the reference to the child that is passed in, not the child itself. So when you reassign child within the method, you're actually reassigning a different child than you pass in (because the reference was copied when it was passed in). Example: code:
crazyfish fucked around with this message at 21:33 on May 10, 2010 |
# ? May 10, 2010 21:29 |
|
What happens when you use array in generic classes or functions? What I would like to do is set key to my map as reference to array so I do something like: code:
If I was to do same thing in C++ I would do code:
Crazy RRRussian fucked around with this message at 21:51 on May 10, 2010 |
# ? May 10, 2010 21:48 |
|
LockeNess Monster posted:What happens when you use array in generic classes or functions? I believe Java already does what you're intending to do, because the hashCode and equals methods of an array primitive already use object identity. See this link: http://stackoverflow.com/questions/1058149/using-a-byte-array-as-hashmap-key-java. If you wanted identity in the map based on array content, you would need to write a wrapper class which uses Arrays.hashCode and Arrays.equals for hashcode and equals on the array contents. While the example uses byte arrays I believe this would apply to double arrays as well. Are you sure you're not just allocating too many arrays or trying to remove entries from the map which aren't the exact same array references as the keys in the map? crazyfish fucked around with this message at 22:00 on May 10, 2010 |
# ? May 10, 2010 21:58 |
|
EDIT: Ok so I am playing around with Java threading and ran into this weird problem:code:
Crazy RRRussian fucked around with this message at 23:47 on May 10, 2010 |
# ? May 10, 2010 23:11 |
|
LockeNess Monster posted:EDIT: Ok so I am playing around with Java threading and ran into this weird problem: I think your culprit is autoboxing. THREAD_DONE.notify() would autobox THREAD_DONE into an Integer which would be different than the primitive you're synchronizing around. Also, are you trying to basically reimplement a CountDownLatch? http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/CountDownLatch.html crazyfish fucked around with this message at 00:18 on May 11, 2010 |
# ? May 11, 2010 00:15 |
|
Yea something like that. But after some perusing in that package I think CyclicBarier should be more appropriate for my problem. What I basically want is just to parallelize a loop in a function that gets called a lot from main thread. This function works on large chunks of data and is trivially paralizable (i.e. no synchronization required for computation). EDIT: Hmm. Well what is a good way to make all threads wait in beginning of infinite loop until my main thread sends them a message? I tried doing notify() and wait() on another object but I seem to be getting a dead lock somewhere Crazy RRRussian fucked around with this message at 00:38 on May 11, 2010 |
# ? May 11, 2010 00:31 |
|
This entire code snippet is confused, and not just because it's apparently reinventing a library class. Variables do not have monitors. Objects have monitors. THREAD_DONE is apparently of type Integer (or Long or something; the point is that it can't be int because you can't synchronize or call methods directly on a primitive, even with autoboxing). So when you synchronize on THREAD_DONE, you're synchronizing on the monitor associated with the object currently stored in that variable. That said, crazyfish's diagnosis is correct: ++THREAD_DONE is compiled as THREAD_DONE = Integer.valueOf(THREAD_DONE.intValue() + 1), so you're notifying on a different object than you synchronized on. Synchronizing on an Integer object is a terrible idea, by the way, because they're sometimes shared throughout the program, so that you can accidentally have completely unrelated pieces of code competing for the same monitor by coincidence and without knowing about it, which is a recipe for deadlock. In general, classes should be synchronizing on objects they themselves allocated and that only they can see.
|
# ? May 11, 2010 00:46 |
|
Is there a non-reentrant lock in Java? God knows, I implemented poo poo like this easily in pthreads with non-reentrant mutexes. EDIT: Pretty much my idea is to have each helper thread acquire a lock twice on non-reentrant lock in beginning of infinite loop. Then the main loop unlock each thread's lock allowing it to do one iteration of the loop until it tries to acquire same lock two time again. Crazy RRRussian fucked around with this message at 00:55 on May 11, 2010 |
# ? May 11, 2010 00:51 |
|
Alright I seem to have gotten around my problems with using ThreadPoolExecutor and CountDownLatch. This link proved to be helpful: http://www.javamex.com/tutorials/threads/ThreadPoolExecutor.shtml EDIT: Sweeeeeeet my program is almost 2x faster now with 2 helper threads. Gonna try it on 8 core machine now Crazy RRRussian fucked around with this message at 01:16 on May 11, 2010 |
# ? May 11, 2010 01:14 |
|
Does anyone have any recommendations for a solid and free / inexpensive code profiler? Perhaps one that's a plugin for eclipse?
|
# ? May 11, 2010 21:56 |
|
nevermind...
|
# ? May 11, 2010 22:13 |
|
geeves posted:Does anyone have any recommendations for a solid and free / inexpensive code profiler? Perhaps one that's a plugin for eclipse? My personal favorite profiler that I use is jProfiler, however whether or not it will work for you depends on your definition of inexpensive. An academic license is $200 and a full license is $500.
|
# ? May 12, 2010 00:03 |
|
crazyfish posted:My personal favorite profiler that I use is jProfiler, however whether or not it will work for you depends on your definition of inexpensive. An academic license is $200 and a full license is $500. Thanks, We're a non-profit, and might be able to qualify for an academic license. I've never been the one to set up the profiler before and with only 2 other developers most is falling on my shoulders since the they are pretty much new to Java and my boss is paranoid about performance and potential memory leaks coming from a C/C++ background.
|
# ? May 12, 2010 01:27 |
|
geeves posted:Thanks, I don't know if it helps but my company just released a free version of our Java troubleshooting tool. You can download it at http://www.appdynamics.com/free. It probably won't help you with the memory angle but you might get some good performance help from it.
|
# ? May 12, 2010 18:58 |
|
I've heard good things about YourKit. They have a 15-day trial that may let you get what you need done. http://www.yourkit.com/home/index.jsp
|
# ? May 12, 2010 23:05 |
|
The JDK has VisualVM. It's been the recent go-to Java profiler for us recently.
|
# ? May 13, 2010 22:07 |
|
I have a pretty basic question, I think. I have an object (dto - just has a bunch of getters and setters) that I'm passing to a servlet, I want to convert the request back to the DTO object. I tried getInputStream but that didn't work. I also tried casting the request, but that didn't work (class cast exception, I was sort of expecting that). How can I get this object back? code:
code:
mister_gosh fucked around with this message at 03:21 on May 14, 2010 |
# ? May 14, 2010 03:09 |
|
How are you actually sending the object to the servlet? If you are doing it from an HTML formm you pass each one of the fields in the object as an http parameter and then get them back out using the getParameter method of the request object. This is obviously tedious and is one of the main reasons you use a framework to do this mapping automatically.
|
# ? May 14, 2010 03:44 |
|
MEAT TREAT posted:How are you actually sending the object to the servlet? There's a crap-ton of multi-leveled data in the DTO so I can't send as params. I just realized that the first param to sendRequest (com.google.gwt.http.client.RequestBuilder) is a String only(?). Maybe I'm limited here afterall... code:
|
# ? May 14, 2010 03:58 |
|
Not sure exactly what you're trying to do, but have you tried just serializing the DTO on the client side, sending it to the servlet, the deserializing it on the server side?
|
# ? May 14, 2010 04:06 |
|
geeves posted:Does anyone have any recommendations for a solid and free / inexpensive code profiler? Perhaps one that's a plugin for eclipse? TPTP has been great for the project I've been working on over the past few months: http://www.eclipse.org/tptp/ It's a bit more memory intensive than VisualVM, but can also give you a bit more detail about what's going on with certain things. Stack traces in the thread visualizer = win. If you're worried about memory leaks, it can also give you allocation details for each type of object. Colonel Taint fucked around with this message at 04:25 on May 14, 2010 |
# ? May 14, 2010 04:17 |
|
RitualConfuser posted:Not sure exactly what you're trying to do, but have you tried just serializing the DTO on the client side, sending it to the servlet, the deserializing it on the server side? Not sure how, perhaps that's what I'm lost about (how to send data to the servlet that is not string or param based).
|
# ? May 14, 2010 04:19 |
|
Assuming the DTO is Serializable, the basic idea is: On the client side: code:
code:
|
# ? May 14, 2010 04:40 |
|
RitualConfuser posted:Stuff
|
# ? May 14, 2010 12:14 |
|
Rookie programmer here, just playing around with I/O for the first time. Any ideas why BufferedReader is only reading the first line of johnny.txt ? code:
|
# ? May 15, 2010 19:03 |
|
Partyworm: Every time an event is fired, you create a BufferedReader attached to a FileReader, read a line, display that line and then your BufferedReader falls out of scope, so it is closed. The simplest way to fix this is to store the BufferedReader as an instance variable in the surrounding class, initialize it in the constructor for that class and then just do "output.setText(buff.readLine());" in the event handler. Internet Janitor fucked around with this message at 19:20 on May 15, 2010 |
# ? May 15, 2010 19:12 |
|
Can somebody recommend some Java frameworks for cluster/distributed computing? Also is there RMI service for Java that is implemented underneath using MPI?
|
# ? May 15, 2010 19:23 |
|
Internet Janitor posted:your BufferedReader falls out of scope, so it is closed.
|
# ? May 15, 2010 19:33 |
|
Partyworm posted:Rookie programmer here, just playing around with I/O for the first time. You're kind of correct - each time the action event occurs, you're making a new FileReader, BufferedReader and String to display. Internet Janitors fix will work.
|
# ? May 15, 2010 20:20 |
|
LockeNess Monster posted:Can somebody recommend some Java frameworks for cluster/distributed computing? Also is there RMI service for Java that is implemented underneath using MPI? No idea of MPI solutions but for clustering applications Terracotta is quite popular. It also works nicely with OSGi which should help you further in modularizing your app. If you want to cluster a specific subset of your program such as data processing, you may want to take a look at Apache Hadoop which is a Map/Reduce based framework for data processing.
|
# ? May 16, 2010 09:15 |
|
Parantumaton posted:No idea of MPI solutions but for clustering applications Terracotta is quite popular. It also works nicely with OSGi which should help you further in modularizing your app. Cool thanks! What I am trying to do is high performance bioinformatics computation on a super computing cluster. Perhaps java is not right solution but I think it could offer nice tradeoff between scalability and ease of the overall design versus the actual speed. Thank you for those links I will research those solutions and see if they are appropriate for my problem.
|
# ? May 16, 2010 09:24 |
|
LockeNess Monster posted:Cool thanks! Sounds like a job for Hadoop distributed processing jobs so definitely worth checking that one out.
|
# ? May 16, 2010 17:40 |
|
|
# ? May 11, 2024 12:03 |
|
I'm writing a really simple IRC bot just to learn poo poo and I'm trying to do something. I don't know what it's called. This is frustrating me. (i am bad at java/programming) Strings have methods like contains and substring and poo poo, so I can do: code:
code:
A tutorial or way of doing something similar or even just Google search terms would be great since I have no idea wtf this is called
|
# ? May 16, 2010 20:20 |