Write a program to calculate the fibonacci and factorals with large answers i.e. using BigInteger, to use multiple threads. Write a similar program to perform matrix multiplication of a large matrix, e.g. 1024x1024 in a multi-threaded manner. (Advanced) Write a thread safe, lockless ring buffer with one reader and one writer, multiple readers and one writer, multiple readers and multiple writers. Try to make this allocation free (ie. doesn't create any objects) Benchmark your code to determine how much faster or slower this is compared with the single threaded version. Take care to ensure your results are reproduceable. Examine how you can determine the optimial number of threads for your each task. Try to adapt your code to use JDK7's fork/join. If anyone has suggestions I would be happy to add them.
Showing posts from March, 2011
- Other Apps
Overview Since Java uses a Garbage Collector it is not possoble to create a dangling reference in pure Java See here for more details However using the Java Library it is possible to create a dangling pointer if you go out of your way to create one. You still cannot create one by accident AFAIK. Creating a dangling pointer deliberately A DirectByteBuffer has the address to a direct area of memory. In C terminology this could be called a pointer. This area of memory is not managed by the GC and must be explicity freed. The DirectByteBuffer manages the creation and cleanup for you so that when the DirectByteBuffer's Cleaner/Deallocator is GC'ed, the memory is freed. This means that indirectly the area of memory is freed when it is no longer used, however it is not directly managed meaning you can pervert this process and create a dangling references like so ByteBuffer bb1 = ByteBuffer.allocateDirect(4096); ByteBuffer bb2 = ByteBuffer.allocateDirect(4096); useReflection
- Other Apps