Included Current Thread in Object.* Events

I decided to take care of another item on my to-do list, item 3: I added the current thread to the Object.* events. That was necessary to accurately update the display in the thread monitor.

Now I’ll start my attempts at a more compact representation. I think I’ll try to add a static instance counter to SyncPointRecorder, which will get incremented during every instantiation of an object. This number will serve as a quasi-unique identifier in Object.

I first considered adding another identifier like that to the Thread class, but I don’t think this is necessary. I’ll use the object ID as thread ID as well. That means threads won’t have consecutive IDs, but that doesn’t really matter.

As to the format… It will be an array of primitive data. I need to store the type of event, which could currently be a byte, and up to three longs (object ID, thread ID, timeout). It would be the easiest to just use four longs (32 bytes), but that would sometimes be a waste of 23 bytes compared to using a byte for the event type and just as many longs as necessary.

So I guess I’ll use a byte array and do some bit math on the longs. The actual format of the even in the byte array will be dependent on the event type.


About Mathias

Software development engineer. Principal developer of DrJava. Recent Ph.D. graduate from the Department of Computer Science at Rice University.
This entry was posted in Concurrent Unit Testing. Bookmark the permalink.

Leave a Reply