Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

Class Level Locking in Java - inspired by Android's AsyncTask implementation...

DEV Community·Somenath Mukhopadhyay·19 days ago
#DWokURUV
Reading 0:00
15s threshold

After many months, I have opened my Java workspace and saw my implementation of Class Level locking, which was inspired by Android's AsyncTask. Here is the source code... package com.somitsolutions.java.training.classlevellockingwithstaticnestedclass ; public class ExampleClass { public ExampleClass (){ } public static InnerNestedClass objInnerNestedClass = new InnerNestedClass (); static class InnerNestedClass { public synchronized void testMethod (){ try { for ( int i = 0 ; i < 10 ; i ++){ System . out . println ( "The testMethod for " + Thread . currentThread (). getName () + " Object" ); Thread . sleep ( 2000 ); } } catch ( InterruptedException e ) { // TODO Auto-generated catch block e .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More